ZScript dynamic versus static(?) arrays

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

ZScript dynamic versus static(?) arrays

Post by Matt »

1. Do static arrays have any equivalent to the dynamic array Find() function?


2. I've got a somewhat large array of things that must be defined for an actor in its beginplay state. After this initial definition the size of this array will never be altered ingame. Is there any meaningful difference in overhead whether I use a static array or a dynamic array for this?


3. Is it possible to have a static array populated by dynamic arrays, and if so what is the syntax?
(e.g., I want to do something like "yodawg[5].push(inputnum)")
User avatar
phantombeta
Posts: 2119
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: ZScript dynamic versus static(?) arrays

Post by phantombeta »

3. Is it possible to have a static array populated by dynamic arrays, and if so what is the syntax?

Code: Select all

Array<[dynarray type]> <variable name> [<static array size>];
Do note, however, that they have some issues. "arr [x] [y]" errors out, so you'll have to copy the dynarray's contents to a function-local dynarray when you need to use ""

Return to “Scripting”