Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, Quad), 761 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
empty pointer? #184219
02/16/08 05:12
02/16/08 05:12
Joined: Feb 2008
Posts: 21
J
jonkuhl Offline OP
Newbie
jonkuhl  Offline OP
Newbie
J

Joined: Feb 2008
Posts: 21
I have a little tank that is suppose to turn and shoot the player when the player gets too close. Working so far.

However, I found that I use the little formula for pointing an object at another alot so I tried to make it its own function:

Code:

//turn to .wdl
//makes an object look at another object
//angleFrom is the vector the object to be looked at is
//angleTo is the euler angle that is turned.
function turnTo(angleFrom,angleTo)
{
var dirB[3];
vec_set(dirB,angleFrom);
vec_diff(dirB,dirB,my.x);
vec_to_angle(angleTo,dirB);
}




Problem is, when I put it in the game and run it, it spits out an empty pointer error.

Code:
 
action enemyTurret
{
//var dir[3];
while (!player){ wait(1); }
my.passable = on;
while(you)
{
my.health = you.health;
if(my.health < 0) { break;}
if(vec_dist(my.x,player.x) < 1000)
{
turnTo(player.x,my.pan);
//vec_set(dir,player.x);
//vec_diff(dir,dir,my.x);
//vec_to_angle(my.pan,dir);
}
else
{
my.pan = you.pan;
}
wait(1);
}
ent_remove(me);
}



The commented lines are what I originally had. I was hoping to give turnTo(); its own WDL file so I could use it in other projects.

The entity* player as of right now always exists and cannot yet be killed or removed from the game.

The problem I keep getting is "empty pointer: turnTo(player.x,my.pan);" What would be causing this and how can I be rid of it and still keep this function?

Last edited by jonkuhl; 02/16/08 05:14.
Re: empty pointer? [Re: jonkuhl] #184220
02/16/08 11:16
02/16/08 11:16
Joined: Jul 2007
Posts: 163
c:\Germany\Bavaria.exe
G_Tos Offline
Member
G_Tos  Offline
Member

Joined: Jul 2007
Posts: 163
c:\Germany\Bavaria.exe
Hi jonkuhl,

perhaps you forgot to initialisize the pointer ENTITY* player; at the beginning of your script...


Spiele zu spielen ist Übung, sie zu machen Kunst!(Zitat)

Re: empty pointer? [Re: G_Tos] #184221
02/16/08 11:20
02/16/08 11:20
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
i think its not the point:
"while (!player){ wait(1); } "
...that means the function does not start without the player?!

Re: empty pointer? [Re: kasimir] #184222
02/16/08 15:52
02/16/08 15:52
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
try while(player!=null){ do this...)
i think !player and player!=null do not do the same strict way

Re: empty pointer? [Re: MMike] #184223
02/16/08 19:54
02/16/08 19:54
Joined: Oct 2004
Posts: 262
Augsburg,Bayern
A
ARAS Offline
Member
ARAS  Offline
Member
A

Joined: Oct 2004
Posts: 262
Augsburg,Bayern
Hi,

you have vectors no numbers in your "function turnTo".
Try this

function turnTo (&angleFrom,&angleTo)

and not

function turnTo (angleFrom,angleTo)

Re: empty pointer? [Re: ARAS] #184224
02/17/08 00:23
02/17/08 00:23
Joined: Feb 2008
Posts: 21
J
jonkuhl Offline OP
Newbie
jonkuhl  Offline OP
Newbie
J

Joined: Feb 2008
Posts: 21
Quote:

Hi,

you have vectors no numbers in your "function turnTo".
Try this

function turnTo (&angleFrom,&angleTo)

and not

function turnTo (angleFrom,angleTo)




Thank you. I seem to recall knowing this in the past, its been a while. But it now works as a separate function.

Re: empty pointer? [Re: MMike] #184225
02/17/08 00:24
02/17/08 00:24
Joined: Feb 2008
Posts: 21
J
jonkuhl Offline OP
Newbie
jonkuhl  Offline OP
Newbie
J

Joined: Feb 2008
Posts: 21
Quote:

try while(player!=null){ do this...)
i think !player and player!=null do not do the same strict way




Can you clarify how !player and player != null is different?

Re: empty pointer? [Re: jonkuhl] #184226
02/17/08 20:48
02/17/08 20:48
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
I don't know but i guess they are not the same ...

!player can exist as a dummy but not an entity...
When you check for player!=null. you will check if it exists in the world :S

At least the !player sometimes for me does not work...



(&angleFrom,&angleTo) the & means it is a pointer.. instead of a plain var number

Re: empty pointer? [Re: MMike] #184227
02/18/08 03:52
02/18/08 03:52
Joined: Feb 2008
Posts: 21
J
jonkuhl Offline OP
Newbie
jonkuhl  Offline OP
Newbie
J

Joined: Feb 2008
Posts: 21
Quote:

I don't know but i guess they are not the same ...

!player can exist as a dummy but not an entity...
When you check for player!=null. you will check if it exists in the world :S

At least the !player sometimes for me does not work...



(&angleFrom,&angleTo) the & means it is a pointer.. instead of a plain var number




So, if I understand you right, (!player) just checks if the pointer has not been defined and (player = null) checks if the pointer has been assigned to an action?

Last edited by jonkuhl; 02/18/08 03:53.

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