Page 1 of 1

How to declare actor's position in variables?

PostPosted: Tue Mar 26, 2013 4:48 pm
by bat78
Hello, who have original way to declare actor's x&y position in variables :)

Re: How to declare actor's position in variables?

PostPosted: Tue Mar 26, 2013 4:53 pm
by lcl
Every actor has a set of variables, that are specific to only that certain actor's certain clone.
These variables are called actor variables, and they include things like: x, y, animpos, animindex, angle, directional_velocity, xvelocity, yvelocity, ...

So, you can set an actor's x and y like this:
Code: Select all
myActor.x = 150;
myActor.y = 300;

And you can also read from the variables, for instance, let's make the actor actor2 move to myActor's x position:
Code: Select all
actor2.x = myActor.x;

Explanations of actor variables and other variables and functions can be found here: http://game-editor.com/docs/script_reference.htm
Hope this helps! :)

Re: How to declare actor's position in variables?

PostPosted: Tue Mar 26, 2013 4:59 pm
by bat78
Ive read the whole reference and ik how to set an actor in x and y position but what i meant is how to make something like that:
Code: Select all
Actor --> Draw Actor --> Script Editor:
int i = actor.x
int a = actor.y
variable = screen_to_actor(&i, &a)


I want each time when the actor move to x the var have to change the value to the x amount that the actor moved
So i can load/save the actor's position :)

Re: How to declare actor's position in variables?

PostPosted: Wed Mar 27, 2013 8:31 am
by skydereign
bat78 wrote:Ive read the whole reference and ik how to set an actor in x and y position but what i meant is how to make something like that:

Then you are over thinking things. All you want to do is store an actor's xy position in a variable. You provided code to do that. Now if you wanted to use a variable that can be used in saveVars it is slightly more involved, especially if you want to save positions of clones. The way to do that is to create int arrays, using cloneindex to locate the position in the array.
Code: Select all
x_array[cloneindex] = x;
y_array[cloneindex] = y;

Re: How to declare actor's position in variables?

PostPosted: Wed Mar 27, 2013 11:16 am
by bat78
You understood what i want, but i did it on another way. Without arrays :o
When an actor is in collation with an another actor the hpmeter.x move:
Code: Select all
hpos=hpos-...


the hpmeter in draw actor have:
Code: Select all
mage_health.x=hpos;
saveVars(...)


And hpos is an normal variable stored in the group that i made to save.
That sounds simple enough and no need to use strings. I mean arrays.
I make a simple test. I make one text actor 0. And i make it with draw actor:
Code: Select all
textactor.textNumber=hpos

So i aways can see how is the hpos when the game start and is it changes and how :D I aways find the way to do everything i want, with different time of course. I submit
in the forums with the idea someone will help me before i get it. Just saying that to tell all that i am not that stupid, because i took a look and i feel like ppl think of me like a stupid xD Thanks for the responsability and sorry for my terrible language :)

I also made that. Counters that aways count the actor's x and y position that you do by moving with arrow keys. Also automatic save them from any change. And loads them automatic:
locationer.exe
(1.38 MiB) Downloaded 140 times