Can store a value into a player or npc, details on the wiki
GetTempVariable
SetTempVariable
New Lua Functions: GetTempVariable and SetTempVariable
Moderator: Team Members
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: New Lua Functions: GetTempVariable and SetTempVariable
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
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.
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
Also heavily comment these function in the server so others can see how I handled accepting multiple data types.
Who is online
Users browsing this forum: No registered users and 0 guests