Preloader not re-preloading same file (only preloading once)

Status
Not open for further replies.
Level 4
Joined
Jul 30, 2014
Messages
18
Hi,

This is a repost, because I accidentally posted this in Advanced Programming :ugly::ugly::ugly:

I was doing some testing with C# lua hot code reload.
I've stumbled upon a bunch of hot code reloaders out there: JHCR, TS-hotcodereload etc.
They just use straight forward Preloader(updated file)
I starting implementing hot code reloader, when I suddenly stumbled upon the problem - Preloader() loads every file only once.


Here is what I mean:
C#:
            trigger escTrig = CreateTrigger();
            // trigger register skip cinematic event
            TriggerRegisterPlayerChatEvent(escTrig, Player(0), "load ", false);
            TriggerAddAction(escTrig, () =>
            {
                string file = GetEventPlayerChatString().Substring(5);
                    Preloader("hcr/" + file + ".txt");
            });

luacode.txt
JASS:
function PreloadFiles takes nothing returns nothing

    call PreloadStart()
    //! beginusercode

    print("Hello World!")

    //! endusercode
    call PreloadEnd( 0.0 )

endfunction

The result is expected. All goooood.
View attachment 403808

Now I change the luacode.txt file
JASS:
function PreloadFiles takes nothing returns nothing

    call PreloadStart()
    //! beginusercode

    print("Some new string")

    //! endusercode
    call PreloadEnd( 0.0 )

endfunction

Now I expect to see Some new string printed when sending chat message load luacode, instead it loads the... old luacode.txt file??
View attachment 403809

Ok, so I tried the next thing...
load nonexistent
Which will preload file that doesnt exist. Alas, nothing happened. Absolutely nothing.
I now create nonexistent.txt with this code
JASS:
function PreloadFiles takes nothing returns nothing

    call PreloadStart()
    //! beginusercode

    print("this file now exists")

    //! endusercode
    call PreloadEnd( 0.0 )

endfunction

And the result is as before... nothing.
I have renamed the nonexistent.txt to test1.txt, ran the load command and voila it now displays what I want.
View attachment 403810


This behaviour seems... incorrect to say the least.
I dont think this is expected, since other hcr engines rely on the same call of Preloader(), which supposedly reads file anew every time it is called.

What could I be possibly doing wrong? :thonk:
I have checked the transpiled LUA code and it looks ok, nothing sneaky or weird, so what could be wrong?
Lua:
local escTrig = CreateTrigger()
      TriggerRegisterPlayerChatEvent(escTrig, Player(0), "load ", false)
      TriggerAddAction(escTrig, function ()
        local file = GetEventPlayerChatString():Substring(5)
        Preloader("hcr/" .. System.toString(file) .. ".txt")
      end)
 
Status
Not open for further replies.
Top