[ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

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!)
Post Reply
Kan3x
Posts: 65
Joined: Tue Nov 08, 2022 4:19 pm

[ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

Post by Kan3x »

Hello.

I have this issue with OnEngineInitialize() and Ultimate Doom Builder.

Basically:

I set a couple of global arrays inside OnEngineInitialize(), since I just need to load them once and that's it, arrays that help me handle several stuff in specific classes etc..
If I run the game through Slade3 or directly gzdoom, everything works perfectly fine, but if I run a map through UDB it seems that the Method doesn't get called.

Is this supposed to happen and I just lack the knowledge on why this is a thing or is it a bug of some sort or am I doing something wrong?

Is there a workaround to the issue? Because I find it pretty annoying having to run custom maps from Slade instead of UDB every time.

Thanks
User avatar
Xeotroid
Posts: 446
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: [ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

Post by Xeotroid »

It works fine for me. Do you have the project folder/PK3 added as a resource in the map options in UDB?
Kan3x
Posts: 65
Joined: Tue Nov 08, 2022 4:19 pm

Re: [ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

Post by Kan3x »

Xeotroid wrote: Fri Jul 18, 2025 12:34 pm It works fine for me. Do you have the project folder/PK3 added as a resource in the map options in UDB?
Yeah, everything works but those arrays in UDB D:

To better illustrate the process:

This is (part) of my Event code:
Spoiler:
This is where I retrieve the array:
Spoiler:
And this is where I actually use that (while checking if the event works)
Spoiler:
If I open up the map in UDB and damage any monster inheriting from WarrensMonster the game crashes and the error says: Array access out of bounds. Size = 0
If I do not open it up in UDB everything goes as planned and I get "Melee" logging after every damage done to those monsters.

I'm really confused If you say it works for you D:
User avatar
Xeotroid
Posts: 446
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: [ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

Post by Xeotroid »

I only tried a minimal example of OnEngineInitialize() containing a printf, and that works fine:

I don't know what could be causing this. All UDB should be doing is run gzdoom.exe with -iwad, -file, -warp, and -skill arguments set.
Kan3x
Posts: 65
Joined: Tue Nov 08, 2022 4:19 pm

Re: [ZSCRIPT] OnEngineInitialize() Not "Working" in UDB

Post by Kan3x »

Xeotroid wrote: Sat Jul 19, 2025 10:49 am I only tried a minimal example of OnEngineInitialize() containing a printf, and that works fine:

I don't know what could be causing this. All UDB should be doing is run gzdoom.exe with -iwad, -file, -warp, and -skill arguments set.
Just to test it out, I just tried the same thing you did here and it worked...

I also tried to see if my arrays were being "filled", again with console.printf() and they do!
It was beyond my comprehension D:

As a last resort I just tried to so if using PostBeginPlay() instead of BeginPlay() in my actor class could do the trick...
and apparently that's the issue...

I'm confused D: really happy that I found what was causing the problem, but still freaking confused because to me it doesn't make sense, unless I'm missing something here.

Do you, perhaps, know what is happening? It is like BeginPlay() is getting called before OnEngineInitialize() when playing in UDB :?:
Post Reply

Return to “Scripting”