Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, TipmyPip, RealSerious3D), 892 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Empty Pointer woes #200653
04/05/08 06:21
04/05/08 06:21
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I've been trying to solve this all day with no luck. I hope someone can give me some help.

These two generator actions work fine by themselves. But when used together in the same level the trapper generator comes up with an empty pointer on "you.spawned_entity = on;"

If I put the trapper generator first, it works and the indian generator has the error.

code:
--------------------------------------------------------------------------
action indian_generator
{

while(1)
{
my.invisible = on;
my.passable = on;
temp.x = my.x +30;
temp.y = my.y + 30;
temp.z = my.z;
wait(2);
you = ent_create("warrior.mdl",temp,act_warrior);
you.spawned_entity = on; //triggers stuff in the warrior action
you.entity_type_id = indian_type; //triggers unique animations

wait(-5);
}
}

action trapper_generator
{
while(1)
{
my.invisible = on;
my.passable = on;
temp.x = my.x +30;
temp.y = my.y + 30;
temp.z = my.z;
wait(2);
you = ent_create("trapper.mdl",temp,act_trapper);
you.spawned_entity = on;
you.entity_type_id = trapper_type;

wait(-15);
}
}
--------------------------------------------------------------------------

(How do we quote code in this new format??)

I've used while(!you){wait(1);} in all possible places...and a hundred other things.

Any suggestions would be greatly appreciated. Thanks

Re: Empty Pointer woes [Re: JazzDude] #200659
04/05/08 07:50
04/05/08 07:50
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
i dont think this will work but you can try

make a ENTITY* ent_h;

ent_h = ent_create("warrior.mdl",temp,act_warrior);
ent_h.spawned_entity = on; //triggers stuff in the warrior action
ent_h.entity_type_id = indian_type; //triggers unique animations

if you wait a frame you could lose your you pointer

no other stupid sugestions yet (;

Last edited by flits; 04/05/08 07:50.

"empty"
Re: Empty Pointer woes [Re: flits] #200660
04/05/08 08:05
04/05/08 08:05
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Yes, you can change its value. Also, to protext yourself against empty pointers:

if(pointer == null)
return;

or if you are sure it will be created, but bot sure of the order:

while(pointer == null)
wait(1);

Also, look in using a "handle." Handles are a class that wrap pointers and manage them for you.

Re: Empty Pointer woes [Re: A.Russell] #200819
04/05/08 17:45
04/05/08 17:45
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Those three ideas failed, but thank you for making me look in some other directions.

I'm an idiot. I spend hours trying to find a complex solution to a simple problem.

The only problem with the two actions was using quotes ("trapper.mdl") instead of making and using a string (string trapper_model = <trapper.mdl>;)

So why did it work when the action was first? Beats me.
Why does it make a difference in this case? Beats me.

But next time I will check the radiator cap before I replace the water pump.

Re: Empty Pointer woes [Re: JazzDude] #200821
04/05/08 18:02
04/05/08 18:02
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Three remarks on your code, JazzDude:

1. Setting invisible and passable in a loop is senseless. Better place that before the loop. Increases performance... ;\)
2. Setting up the temp vector and then waiting 2 frames and finally using it is a source for hard to find errors. If you set up temp to vertain values you should use them immediately. Otherwise other functions may overwirte you temp vector with arbitrary data.
3. Be sure to wait at least one frame in your act_trapper and act_indian action, before reading out spawned_entity and entity_type_id.


Always learn from history, to be sure you make the same mistakes again...
Re: Empty Pointer woes [Re: Uhrwerk] #200831
04/05/08 19:18
04/05/08 19:18
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
As you've noticed in the past, Uhrwerk, I don't use C-script.
I use Klutz-script, so constructive criticism is always very welcome.

\:\) Thanks.

Re: Empty Pointer woes [Re: JazzDude] #200855
04/05/08 21:37
04/05/08 21:37
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
That's what we all use, JazzDude. It's just a question of stamina. The longer you do it, the more complex bugs you'll produce. ;\)


Always learn from history, to be sure you make the same mistakes again...
Re: Empty Pointer woes [Re: Uhrwerk] #200926
04/06/08 07:28
04/06/08 07:28
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I don't have any problem when running your script, maybe
the problem is somewhere else in "act_warrior" or
"act_trapper".


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1