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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, 7th_zorro, 1 invisible), 890 guests, and 2 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
Page 1 of 2 1 2
player problem #291447
09/25/09 11:16
09/25/09 11:16
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline OP
Member
DAVIDMORETON  Offline OP
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Can anyone help please?
I need to 'call' the player in a function such that it will follow the platform it is standing on, simple example below:-

Function moveit
{
while (platform.x<200)
{
platform.x+=2*time;
player.x+=2*time;
wait(1);
}}

Result:- empty pointer in moveit: player.x+=2*time;

I can't seem to find a way to call the player in a function as it has already had it's action assigned, so I can't use 'entity* player'

Is there a way to do this?

yours hopefully, David

Top

Re: player problem [Re: DAVIDMORETON] #291451
09/25/09 11:39
09/25/09 11:39
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
The empty pointer error means that "player" doesn't relate to anything. You need to make sure that you set the player pointer to a valid entity either by using it in an action like "player = me" or from the result of an ent_create call >> "player = ent_create(...)".

Re: player problem [Re: DJBMASTER] #291490
09/25/09 15:28
09/25/09 15:28
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline OP
Member
DAVIDMORETON  Offline OP
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Thanks BJDMaster for your reply,
I have added player=me; to the player01 script
and entity* player; to my running script ...........
The player still passes through the wall of the 'box' when it moves.
what am I doing wrong please?

sincerely, David

Re: player problem [Re: DAVIDMORETON] #291499
09/25/09 17:01
09/25/09 17:01
Joined: Aug 2003
Posts: 63
UK
ptrc1c Offline
Junior Member
ptrc1c  Offline
Junior Member

Joined: Aug 2003
Posts: 63
UK
Go to Online Tutorial at the top left of the screen-workshop 11
You need to declare an ENTITY* ,say traveller

ENTITY* traveller;

then in your action somewhere

action traveller_with_pointer()
{
traveller = me;
etc...
}


Then use traveller.x in your function

Re: player problem [Re: ptrc1c] #291545
09/26/09 09:38
09/26/09 09:38
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline OP
Member
DAVIDMORETON  Offline OP
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Thanks ptrc1c for your reply.

The problem is that the 'player' is already assigned in the 'actions' box (PIBiped01), this means that I can't call another 'action' to apply to it. (or of I can, I don't know how to do it)

I have tried everything I know to refere to the player, but nothing works. As the game is 3/4 finished (about three years work) I don't want to rewrite the whole script.

All I need is some means of refering to the player so that I can call it in a function.

If you can help, it would be great.
sincerely David

Re: player problem [Re: DAVIDMORETON] #291551
09/26/09 11:49
09/26/09 11:49
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
If you are definately using the pointer "player" in all your script then it shouldnt be a problem.

Its probably just a timing issue. That is, if the "moveit" function starts BEFORE player gets assigned, then the problem occurs...
Here are two suggestions for "moveit" to bypass the problem, my perferred one is the second one.

Code:
//commonly used process
function moveit
{ 
   while(player==NULL)    {  wait(1);  }
   while (platform.x<200)
   {
      platform.x+=2*time;
      player.x+=2*time;
      wait(1);
   }
} 


//my preferred process
function moveit
{ 
   while (platform.x<200)
   {
      platform.x+=2*time;
      if(player!=NULL)    {  player.x+=2*time;  }
      wait(1);
   }
}


Mind you, I assume you are aware that this code isnt checking to be sure the player is actually ON the platform?
If they step off it whilst it is moving, they'll continue to be moved by it....


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: player problem [Re: EvilSOB] #291555
09/26/09 12:35
09/26/09 12:35
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline OP
Member
DAVIDMORETON  Offline OP
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Hello evilSOB,
Many thanks for you reply. I have entered your first script exactly as stated, and got:-

"bad or missing parameter too complex"

I then tried your second (prefered) solution, the platform moved, but the player stayed put!!

Checked I had not made a mistake in the coding.

In the past (while trying to sort this out) I usually get "empty pointer" when refering to the 'player' Don't understand that either!
If you can help, I would be very pleased. NOTE I am working in c-script

sincerely, David

Re: player problem [Re: DAVIDMORETON] #291558
09/26/09 13:14
09/26/09 13:14
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I myself dont use c-script, but did do some c-script->lite-c conversions in the past.
So Im helping in lite-c in my head, then converting to c-script as I type my posts.
So there may be some conversion errors there.

For instance, the 'bad or missing parameter' error MAY be due to both versions of 'moveit'
MAY need parameter brackets after thier names. eg "moveit()" instead of just "moveit".
In lite-c you need to, but it seems optional in c-script.
Put em on and try and see if the error goes away.

Anyway, regardless of the brackets issue, if the second one didnt work, there are several possible reasons.
1> The "moveit" function is not being run.
2> The player pointer is not pointing to your player entity.
3> The player is a physics entity, and so cannot be moved with simple co-ordinate adjustments.
4> There is another action somewhere limiting the players movements in the x direction.

I think options #1 or #3 are the most likely causes...

So unless you can supply some of the code then I cant help out more...
Say, the opening part of the players action? (up to the start of its while loop).
Or are you using the templates? In that case try replacing "player" with "plBiped01_entity" in the "moveit" function.
Otherwise Im out of ideas of how to help.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: player problem [Re: EvilSOB] #291564
09/26/09 13:53
09/26/09 13:53
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline OP
Member
DAVIDMORETON  Offline OP
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Hi evilSOB,
Many thanks fo your reply and help, below is what I've done:-

room with box like lift in it, plus player with action PIBiped01 assigned.
player is in the box (open top) so that I can see if it moves with box.
code:-
(all required 'includes' in place)

entity* platform;

function moveit
{
while(platform.x<300)
{
platform.x+=2*time;
{
if(player!=NULL)
{
player.x+=2*time;
}
wait(1);
}}

action platform1
{
platform=my;
my.enable_click=on;
my.event=moveit;
}

Player still stays put, but the box moves nicely!!

Any thoughts? hopefully, David

Re: player problem [Re: DAVIDMORETON] #291566
09/26/09 14:33
09/26/09 14:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hmm, Ive never really used the templates at all, overly complex for my tastes.
I like to do things my way, and the template make that hard.
But hey, thats my problem, back to yours....

The "PIBiped01" templates dont actually use the "player" pointer, unless youve modded it in.
They use their own pointer which is called "plBiped01_entity" instead.

So try changing "moveit" to be this, and see how it goes...
Code:
function moveit()
{
   while(platform.x<300)
   { 
      platform.x+=2*time;
      if(plBiped01_entity!=NULL)    {   plBiped01_entity.x+=2*time;   }
      wait(1);
   }
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 1 of 2 1 2

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