#:Awake Function Bug (in global scripts)

49 messages · Page 1 of 1 (latest)

queen charm
#

Okay I figured out another issue that is probably related to this?

#

For some reason, the ShowBubbleMessage only appears in a save if the map has been finalised or the script is compiled. It doesn't carry over through editor saves though so it won't appear if the map is saved and loaded again through the editor

#

Additionally, if you finalise the map while that code has created a field, the field never gets deleted on the next save(s) until scripts get recompiled. I guess I can use a if(GetEditMode not) around the SetFcSave to create a fix for this but I feel like what I found is another bug?

obsidian lion
queen charm
#

Yes, but in future editor loads it doesn't appear (until the map is finalised/compiled again)

#

sorry that was bad wording xd

#

Hope that makes more sense

obsidian lion
#

got it

queen charm
#

Wait I think I might misunderstand how Awake works

#

It looks like :Awake only ever runs after the map is recompiled or finalised

#

And doesn't when game is loaded for the 'first time' (like how CW4 worked iirc?)

#

Ima test a little more just to confirm what I'm saying

#

Right so I used PlaySound to test this (in the :Awake func)

#

And yeah, it only ever played the sound when the script was compiled

#

Never played when loading the save or even the save if it was finalised

#

I've also tested by using ShowConversation and it's the same thing

#

Also, I tested :Gameloaded with this code and it never ran at all after save and loading or even finalising and loading

#

I'M SO CONFUSED WHAT

obsidian lion
#

You finalized it, played it, saved it and then loaded it and it didnt work?

queen charm
#

One time I compiled, saved and loaded

#

Another time I compiled and finalised and then loaded

obsidian lion
#

I think GameLoaded might only run when you load a map save that you've already started.

queen charm
#

I'm really confused though because this stuff worked the last time I did this

obsidian lion
#

Okay yeah that is weird.

queen charm
#

Idk if maybe a new build has bugged something out or maybe I'm being dumb

#

I have the global script identical to how my last map had it, obviously with the .irpl script parameter matching the new script

#

My old map still works even after recompiling and making a new finalised save, so it must be something I've done?

obsidian lion
#

Oh

#

That I couldn't tell you. You could try porting all your scripts to a fresh map; I find sometimes "undead" scripts happen when editing the same map frequently where there seem to be multiple outdated copies of scripts running on top of the newest version for some reason.

queen charm
obsidian lion
#

I never ran into it but that doesn't mean it never happened.

queen charm
#

I've never experienced these issues before so I'm really confused

#

Wait my old map used this thing I did where I went

  @Init
:Init...```
#

Lemme see what happens when I change that to :Awake and :Gameloaded by themselves

#

Oh okay... I think I get it now

#

:Awake only runs on a game compile now

#

Instead of when it's loaded for the first time like last games

#

So using :Awake and expecting it to work like how it did in old games was really throwing me off

obsidian lion
#

No, Awake definitely runs every time the script starts executing.

queen charm
#

hm

obsidian lion
#

I think some functions fail when used in Awake, but I thought they'd been fixed.

#

:Once is the function that only runs on compile/map start.

queen charm
#

Huhhh

#

Oh

#

Yeah but :Once runs after the game is unpaused, while I'm trying to get it so the function runs instantly one time

#

In CW4 I'd use Awake for that but obviously that doesn't work here from what I can see atm

#

Wait no the bubblemessage is appearing now

#

I'm so confused xd