Set up an array in DECORATE?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Set up an array in DECORATE?

Post by Ceeb »

How exactly do you define an array for an actor? Is it the same as setting up a user variable?
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Set up an array in DECORATE?

Post by Gez »

Yes. See [wiki]DECORATE expressions[/wiki]
  • User Variables — user variables are defined as "var int user_(name);" in actor properties
  • User Arrays — user arrays are defined as "var int user_(name)[(size)];" in actor properties
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: Set up an array in DECORATE?

Post by Ceeb »

Oh. Not where I expected it to be! Thank you Gez. :)
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: Set up an array in DECORATE?

Post by Ceeb »

Must be doing something wrong... Are DECORATE arrays started at zero? Sometimes the ball will curve, sometimes it flies straight. It should curve the other way...

Code: Select all

ACTOR LightBeamProjectile
{
    Radius 8
    Height 8
    Speed 20
    Damage 8
    Scale 0.4
    Projectile
    Renderstyle Add
    Alpha 0.6
    +RIPPER

    var int user_weave;
    var int user_weavearray[2];

    States
    {
    Spawn:
        TNT1 A 0 A_SetUserArray("user_weavearray",0,-2)
        TNT1 A 0 A_SetUserArray("user_weavearray",1,2)
        TNT1 A 0 A_SetUserVar("user_weave",user_weavearray[random(0,1)])
    Flying:
        LBPR A 1 A_SpawnItemEx("LightBeamProjectileTrail")
        TNT1 A 0 A_Weave(user_weave,user_weave,1.0,1.0)
        Loop
    Death:
        TNT1 A 0
        Stop
    }
}
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Set up an array in DECORATE?

Post by Gez »

You simply forgot about the Curse Of The Spawn State(tm): an actor only runs its action function when it transitions to a new state, and thus does not run the code from its spawn state...
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: Set up an array in DECORATE?

Post by Ceeb »

Crap! I usually tend to be good about that. :oops: Thank you Gez...
Locked

Return to “Editing (Archive)”