[Lua] Reload scripts in-game on the fly, ANY engine, ANY rev menu

Shout-Out

User Tag List

Results 1 to 12 of 12
  1. #1
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Reload scripts in-game on the fly, ANY engine, ANY rev



    Reloading a specified script in-game using a small Lua script


    Content
    • Introduction
    • Which one to use?
    • How to set it up
    • How to use
    • The script - utilizing a chat hook
    • The script - utilizing a gossip script
    • Extra information



    Introduction
    Are you one of those guys who uses a newer ArcEmu rev than 3089? Or are you one of those guys running a non-ArcEmu server with a Lua Engine? And are you wanting to reload a script in-game? Well, then this is for you.


    Which one to use?
    If you run a Lua engine which has a chat hook then I recommend the one with the chat hook as it's faster to type it immediately instead of having to open up a gossip and a codebox.
    If you do not have a Lua engine with a chat hook then the gossip script is for you. Using the codebox you will be able to specify which script you want to load.


    How to set it up?
    If you're using the chat hook version then it's a simple matter of drag and drop in your scripts folder just as you would with any Lua script.
    If you're using the gossip version you'll have to add a gossip item to your database first, change the ITEM_ID_GOES_HERE to the newly added item and add the Lua script to your scripts folder. Don't know how to make a gossip item? Then I point you in the direction of this guide: Sign In


    How to use?
    Using the chat hook version you can simply type: #ReloadScript <name of the script> . Thus if I have a script called "MyLua" in my scripts folder I type "#ReloadEngine MyLua".
    The gossip script uses the codebox to ask for the script name. Thus if you have the codebox open and you have a script called "MyLua" you simply have to type "MyLua" in the codebox.


    The script - utilizing a chat hook
    Code:
    function ReloadScript_ChatHook(event, player, message, type, language)
    	local _, end_index = message:find("#ReloadScript")
    	if (end_index) then
    		local path = message:sub(end_index+2)
    		if path ~= "" then
    			player:SendBroadcastMessage("Reloading " .. path .. ".")
    			dofile("scripts/" .. path .. ".lua")
    		else
    			player:SendBroadcastMessage("No specified file.")
    		end
    	end
    end
    
    RegisterServerHook(16, "ReloadScript_ChatHook")

    The script - utilizing a gossip script
    Code:
    function ReloadLua_Trigger(item, event, player)
    	item:GossipCreateMenu(50, player, 0)
    	item:GossipMenuAddItem(0, "Reload script.", 1, 1)
    	item:GossipMenuAddItem(0, "[Exit]", 2, 0)
    	item:GossipSendMenu(player)
    end
    
    function ReloadLua_Select(item, event, player, id, intid, code)
    	if (intid == 1) then
    		if code ~= nil and code ~= "" then
    			player:SendBroadcastMessage("Reloading " .. code .. ".")
    			dofile("scripts/" .. code .. ".lua")
    		else
    			player:SendBroadcastMessage("No specified file.")
    		end
    		player:GossipComplete()
    	end
    	
    	if (intid == 2) then
    		player:GossipComplete()
    	end
    end
    
    RegisterItemGossipEvent(ITEM_ID_GOES_HERE, 1, "ReloadLua_Trigger")
    RegisterItemGossipEvent(ITEM_ID_GOES_HERE, 2, "ReloadLua_Select")

    Extra information
    What does dofile do?
    The dofile(path) function is a standard function of the Lua interpreter. It immediately executes the specified path as a chunk in the Lua interpreter. Because Lua functions are anonymous reloading a script is basically nothing but assigning variables.


    Anony-.. wut?
    You heard that right, folks. Lua functions are anonymous. What does that mean? It means they actually do not have a name. But, but, if I do function myFunction() I'm giving it a name, am I not?
    Yes and no. It's eye candy, because what you are actually doing is myFunction = function(). Thus declaring a function is nothing but assigning a function to a variable.


    What's this _ thingie I noticed in "local _, end_index"?
    That's called a dummy variable. Sometimes functions return more than one piece of information, but we don't need the others. By using the dummy variable we are basically deleting pieces of returned information and assigning the other information to the other specified variable, thus gaining memory effiency.

    [Lua] Reload scripts in-game on the fly, ANY engine, ANY rev
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1615
    Join Date
    Sep 2007
    Posts
    4,558
    Thanks G/R
    151/147
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Not only a release that benefits everyone who uses Lua, but also explained very clearly about how it works and how to work it.

  3. #3
    Dr. Cheasterfield's Avatar Contributor

    Reputation
    89
    Join Date
    Jun 2009
    Posts
    61
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh such a good share !
    Really useful ! +Rep

  4. #4
    Reflection's Avatar Legendary
    Reputation
    783
    Join Date
    Mar 2008
    Posts
    3,377
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very nice! Outstanding script and presented well. +4

    Nicely done

    Freelance Digital Artist
    https://reflectionartwork.deviantart.com
    You did not desert me
    My brothers in arms


  5. #5
    Ground Zero's Avatar ★ Elder ★
    Reputation
    1132
    Join Date
    Aug 2008
    Posts
    3,504
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great release, so you did figure out how to fix this in the end. +6
    Last edited by Ground Zero; 01-23-2010 at 03:48 PM.

  6. #6
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep worthy. +rep x3

  7. #7
    Proxes's Avatar Member
    Reputation
    31
    Join Date
    Dec 2008
    Posts
    256
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great Job Very usefull

    Rep for you buddy

  8. #8
    Claiver's Avatar Member
    Reputation
    138
    Join Date
    Mar 2009
    Posts
    217
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So few comments for such a revolutionary release, I mean, first I see this being able in Lua (regardless of the fact that I see this after what, 5 months?).
    I never knew you wrote this, Dyna!

    +Rep from me, to you.

  9. #9
    Breakdawn's Avatar Active Member
    Reputation
    39
    Join Date
    Jun 2009
    Posts
    266
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So this works with Mangos I guess? (: Or am I wrong?

  10. #10
    Trle94's Avatar Contributor
    Reputation
    167
    Join Date
    May 2009
    Posts
    329
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its is for arcemu and arcemu bassed cores that support lua :P Good job Dynashock +Rep from me


  11. #11
    Confucius's Avatar Super Moderator The Idiot

    CoreCoins Purchaser Authenticator enabled
    Reputation
    1401
    Join Date
    Oct 2007
    Posts
    2,668
    Thanks G/R
    290/295
    Trade Feedback
    7 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is great for servers were you don't have access to the world.exe to do reloadscripts or only want to reload one script +Rep 4

  12. #12
    bendaferi's Avatar Active Member
    Reputation
    34
    Join Date
    Jun 2008
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you I found this script really useful. Since I don't have to restart my server over and over again.
    +Rep

Similar Threads

  1. [ArcEmu] Enable Reloading Tables "On The Fly"?
    By Jeordy in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 01-07-2011, 02:29 PM
  2. [Lua Script] [Request] LUA Script on game objects
    By Ultradethv2 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 08-10-2010, 10:17 AM
  3. [Lua Script] How to I reload lua scripts in-game ?
    By Wheeze201 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 06-27-2010, 08:28 AM
  4. [Lua] Reloading Scripts with a lua script
    By thetrueman2 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 04-30-2010, 07:20 AM
  5. LUA scripting -- Making game objects cast spells.
    By Jotox in forum World of Warcraft Emulator Servers
    Replies: 6
    Last Post: 05-08-2008, 03:44 PM
All times are GMT -5. The time now is 11:45 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search