• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Question - Force reload of required lua script

Soandso2

Well-known member
Is there any way to force reload a required Lua?

Example:
foo.Lua contains a require("bar")

While foo.Lua is running, I make a change to bar.Lua. Is there anyway to force reload bar.Lua other than exiting and reloading foo.Lua?
 
Considering the lack of replies to the question, I presume the answer is "No, you cannot reload a required/included script by any other means than terminating the master script and running it again".
 
I think the deeper question is why would you need to do this. I can't imagine the need to completely restart a script unless it's not designed correctly. Does the script load something on start that you later need to reload for example? Then I would have a bind to reload that data rather than restart the script. XY problem here perhaps?
 
I think the deeper question is why would you need to do this. I can't imagine the need to completely restart a script unless it's not designed correctly. Does the script load something on start that you later need to reload for example? Then I would have a bind to reload that data rather than restart the script. XY problem here perhaps?
Master script is stand-alone and works as intended. Included script is an addition with code that you do not want to include in the master script - it is in development and you might be tweaking or rewriting parts. You make a change and you want to see if the change worked. It is not so much a "why would you want to", but a "is it at all possible to" question.
 
Yes, it's possible. I still contend this is an XY problem.

This is our "working as intended script"
Lua:
local mq = require("mq")
while true do
    print("lua_one running...")
    mq.delay(1000)
end

This is our testing script that will stop and restart the first script
Lua:
local mq = require("mq")

print("lua_two running...")

print("stopping lua_one...")
mq.cmd("/lua stop lua_one")
mq.delay(2000)

print("restarting lua_one...")
mq.cmd("/lua run lua_one")

If you run these you'll see that script one will print out "lua_one running" every second...
Running the second one will stop, wait 2 seconds and then start (restart) the lua_one script.
 
i think you misunderstood the question coldblooded, he wants to know if you can make change to a required Lua file, and then have the main script reload the changed Lua file, remember required Lua files dont run, they just contain code, like the write.Lua by knightly.
 
Oh, sorry! Thanks for the explanation Kaen.

Yes, it's still possible. Just "depends" on how much control you have over the main script file.

Basically, it works like this

Original
Lua:
local mymodule = require("mymodule")


-- I hate my module, let me reload it!
package.loaded["mymodule"] = nil
mymodule = require("mymodule")
 
Oh, sorry! Thanks for the explanation Kaen.

Yes, it's still possible. Just "depends" on how much control you have over the main script file.

Basically, it works like this

Original
Lua:
local mymodule = require("mymodule")


-- I hate my module, let me reload it!
package.loaded["mymodule"] = nil
mymodule = require("mymodule")
Aaaha there we go. Thank you so very much. :)
 
Question - Force reload of required lua script

Users who are viewing this thread

Back
Top
Cart