How can you use regular integers in ZScript actor state blocks?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
doomzie
Posts: 94
Joined: Sat Apr 30, 2022 4:26 am

How can you use regular integers in ZScript actor state blocks?

Post by doomzie »

Hi,

I need some help with something that is seemingly very simple, but I can't get it to work.

I read a lot of wiki documentation and tried to figure out some examples, but I don't understand why my "regular integer" variable doesn't work.

So I converted a DECORATE actor from flametraps.pk3 (realm667) to ZScript and everything works fine, but the modification here is to no longer use the ACS Args[] to reset one of the integers (user_shotdelay) back to its initial value, but a custom defined user int variable with a value set by the editor in UDMB in the map.

The ZScript class works fine if I don't add that regular int (shotcountdelay), but then I can't reset user_shotdelay to its initial value, and thus it will only shoot once.

So basically when I add the regular int, seemingly nothing happens anymore and I can't tell where exactly it's "hanging" or why nothing happens.

Can anyone explain how to deal with this?

Thanks in advance.



ZScript Actor Class:
Spoiler:
7Soul
Posts: 44
Joined: Sat Mar 13, 2021 6:47 pm

Re: How can you use regular integers in ZScript actor state blocks?

Post by 7Soul »

Add NoDelay in your Spawn state, like so:

Code: Select all

Spawn:
MODL A 0 NoDelay {shotcountdelay=user_shotdelay;}
Otherwise the engine skips the line. Source. Dunno if this fixes everything but it's the first problem I noticed
doomzie
Posts: 94
Joined: Sat Apr 30, 2022 4:26 am

Re: How can you use regular integers in ZScript actor state blocks?

Post by doomzie »

Ok, that resolved it =) Code works just fine now. Thanks a lot!

I read it at some point in the Wiki. My bad. Noob issues you know =)

Have a nice day sir!
Post Reply

Return to “Scripting”