New Lua Functions: GetTempVariable and SetTempVariable

Discussions on development of both the EQ2Emulator LUA Script Engine and Script specifications

Moderator: Team Members

Post Reply
Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

New Lua Functions: GetTempVariable and SetTempVariable

Post by Jabantiz » Fri May 24, 2013 7:03 pm

Can store a value into a player or npc, details on the wiki

GetTempVariable
SetTempVariable

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: New Lua Functions: GetTempVariable and SetTempVariable

Post by Jabantiz » Sat May 25, 2013 1:18 pm

After talking with foof, these have been modified to hold pointers as well as strings, current supported values are string, spawn, zone, item, and quest. SetTempVariable is still used the same way, however if you pass a value of "nil" for a variable that variable will now be deleted so when you are done using a variable set it to nil

Examples

Code: Select all

function hailed(NPC, Player)
    SetTempVariable(Player, "SpawnPointer", NPC) -- This will store the npc in a temp variable on the player who hailed it
end

function SomeFunctionInADiffrentSpawnScript(NPC, Player)
    -- Get the spawn pointer we stored in the players temp variables
    Spawn = GetTempVariable(Player, "SpawnPointer")
    -- Check to make sure the pointer is valid
    if Spawn ~= nil then
        -- Lets change that spawns visual state
        SpawnSet(Spawn, "visual_state", 1111) -- FYI - made up # for visual state, no clue if it is valid
        -- No longer need the spawn pointer so lets clear it
        SetTempVariable(Player, "SpawnPointer", nil)
    end
end
It is important that the scripter knows what the type of the value is stored in a variable as well as clearing the variable when done.

Also heavily comment these function in the server so others can see how I handled accepting multiple data types.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests