Actor variable

Non-platform specific questions.

Actor variable

Postby Agusstosus15 » Thu Oct 20, 2011 4:55 pm

how to change declared Actor variable?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: Actor variable

Postby Hblade » Thu Oct 20, 2011 6:30 pm

what do you mean?

Code: Select all
MyActor.actorvariable=5;


If you want to manually declare an actor variable you need an array.
Code: Select all
short int ActorVar1[65535];


Then you'd want to define actornames to the variable
Code: Select all
#define _Player ActarVar1[0]
#define _Enemy1 ActorVar1[1]


And so fourth. but this will not work with clones or new-created actors unless you script something insane.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Actor variable

Postby savvy » Thu Oct 20, 2011 7:57 pm

yeah, basically if you are editing an actor variable in the actor you want to change just use
Code: Select all
variable = 0;

or whatever number...
if your editing another actors actor variable use
Code: Select all
actor.variable=0;

this is what Hblade said, i am merely trying to make it seem more simple :D

savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Actor variable

Postby Agusstosus15 » Thu Oct 20, 2011 8:26 pm

int i;
postac_rycerz_pion.sila=+1;

i=getclone ("postac_rycerz_pion.0")->sila;

if (i>3)
{
DestroyActor("Event Actor");
}

sila is Actor variable extended it's structure i declared in variable bar in script editor
what's wrong with code?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: Actor variable

Postby EvanBlack » Thu Oct 20, 2011 9:29 pm

Well.. there doesn't appear to be anything wrong with it just by looking at this small piece. More information is needed to know where this code is and how its being called.

By looking it appears to be in an event but the thing is, it looks like every time this is called after the third time it destroys the actor which holds this event..

If you have 3 actors with this event, and all 3 actors call this event 1 time, then all actors with this event will be destroyed. Any actors created after that call this event will also be destroyed.

In the event that postac_rycerz_pion.0 is destroyed, you will most likely get a reference to a NULL pointer or just a read error. if this is called anywhere after postac_rycerz_pion.0 is destroyed. But because getclone returns a null actor, i just might always = 0 after postac_rycerz_pion.0 is destroyed so any actors calling this even even if there is an actor postac_rycerz_pion.1 which sila will keep increasing by 1 postac_rycerz_pion.0 doesn't exist so i is always less than 3 so DestroyActor() never gets called.


Thats everything I can say about this segment of code.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: Actor variable

Postby skydereign » Thu Oct 20, 2011 9:48 pm

Your code is using =+, instead of +=. If you wanted to change sila, then you need to use +=. Otherwise you are just setting sila to 1.
Code: Select all
int i;
postac_rycerz_pion.sila+=1;

i=getclone ("postac_rycerz_pion.0")->sila;

if (i>3)
{
    DestroyActor("Event Actor");
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Actor variable

Postby Agusstosus15 » Thu Oct 20, 2011 10:22 pm

thanks black I know already that :)
thanks sky , that was it += :)

big thanks for both of you

sila is different for any actor in game, right?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: Actor variable

Postby EvanBlack » Thu Oct 20, 2011 11:42 pm

with the code you are using it changes sila of all the actors with that name, if you want to change one actor clone then you have to use get clone and have it reference the variable.

Code: Select all
getclone ("postac_rycerz_pion.0")->sila += 1; // This changes postac_rycerz_pion.0's sila variable only



There are a couple of ways to get the clone or actor you want. The easiest method depends on what is calling the function and which clone you want to access.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: Actor variable

Postby Agusstosus15 » Fri Oct 21, 2011 12:18 am

but only actors with that name, god thanks :)
ok I got it, thank you once again
night for me
day for you
see ya:)
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: Actor variable

Postby skydereign » Fri Oct 21, 2011 12:20 am

Using actorname.actorvar does not change every clone of actorname's variable. It uses the default struct, so normally the lowest indexed clone. If you just created a clone in the event, it will use the newly created actor. So using getclone and the Actor* is the same as using the struct directly if you use getclone to access the lowest clone.
Code: Select all
actor.r=0; // sets the r of the clone with the lowest cloneindex
CreateActor("actor", "icon", "(none)", "(none)", 0, 0, false);
actor.r=0; // sets the newly created actor's r to 0
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest