Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, bigsmack, monarch), 1,240 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
checking an entitiy's position w/out attaching an action? #314728
03/10/10 16:08
03/10/10 16:08
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
I'm messing with the Earthball example and I want to make the ball respawn (move to a new point on the z-axis) when it's z-coordinate is below a certain value. Can I do this by using a piece of code like;

under function main()

if eBall.z < -100
{eBall.z = 500;}

eBall is the pointer for the entity

or do I have to create an action and attach it to the entity?

if I have to attach an action how do I do that after the entity is already created? Meaning, what is the function to attach an action to an already created entity?

I know this is incredibly simple but my mind isn't working today...

Re: checking an entitiy's position w/out attaching an action? [Re: Lecithin] #314730
03/10/10 16:13
03/10/10 16:13
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
When you scroll to the bottom of the earthball.c file you'll see a while(1) loop to control the camera.

Before the wait(1) at the end of that while loop you can insert some code to check the z value of the eBall entity:
Code:
if(eBall.z < - 100)
{
  eBall.z = 500;
}



edit:
You cannot attach a function to an already created entity.
But you could attach an already created entity to a function.
So this could be another way:
Code:
void earthball_Control(ENTITY* _ent)
{
  my = _ent;
  while(my)
  {
    if(my.z < -100)
    {
      my.z = 500;
    }
    wait(1);
  }
}


Now add this line to your main function _before_ the while(1) loop:
Code:
earthball_control(eBall);



Last edited by Xarthor; 03/10/10 16:16.
Re: checking an entitiy's position w/out attaching an action? [Re: Xarthor] #314736
03/10/10 16:40
03/10/10 16:40
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
GAH scratch this entire post! I had a simple syntax error and need more sleep....

thanks for your help

Last edited by Lecithin; 03/10/10 16:41.
Re: checking an entitiy's position w/out attaching an action? [Re: Xarthor] #314737
03/10/10 16:41
03/10/10 16:41
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: Xarthor
You cannot attach a function to an already created entity.
Are you sure of this Xarthor?

Shouldnt this work?
Code:
action earthball_Control()
{  while(my)
   {  if(my.z < -100)
      {  my.z = 500;  }
      wait(1);
   }
}

function main()
{
   ...
   ...
   me = eBall;
   earthball_Control();     //OUTSIDE of any loop
   ...
   ...
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: checking an entitiy's position w/out attaching an action? [Re: Lecithin] #314738
03/10/10 16:42
03/10/10 16:42
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Well you may need to read my post again.
The correct syntax for an if branch is:
Code:
if(condition)
{
  instruction;
}



so please write:
Code:
if(eBall.z < -100)
{
  eBall.z = 500;
}



Re: checking an entitiy's position w/out attaching an action? [Re: EvilSOB] #314739
03/10/10 16:44
03/10/10 16:44
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
True, that is seems to be another possibility.
So, no, I'm not sure anymore wink

edit:
When you look at my first post you'll see that I presented the same idea.
While looking closer at your code I'm not sure if you can call an action like that. But it should definatly work when you'd write function instead of action.

Last edited by Xarthor; 03/10/10 16:49.
Re: checking an entitiy's position w/out attaching an action? [Re: Xarthor] #314744
03/10/10 17:02
03/10/10 17:02
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
You can CALL actions that way with no problem, I do it all the time.

But Ive never tested the process far enough to know if these actions
self-terminate when the entity they've been attached to gets removed
by a different function.

[EDIT]Im purely discussing the 'cant attach an action to an existing entity' issue.
I agree with all else youve said / suggested.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: checking an entitiy's position w/out attaching an action? [Re: EvilSOB] #314754
03/10/10 18:08
03/10/10 18:08
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
You can call actions that way. A action is the same as a function. The only differents:
action can not return a Parameter
action shows up in WED


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