LUA Functions Request
Moderator: Team Members
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
Nope, since all our spawn_ids are unique now you will not have to specify the type of spawn it is when you are spawning a new spawn. It will automatically determine that for you. You just have to supply a valid id.
Since the LUA stuff is global, I need a reference to which zone it was called from. That is why the first parameter is a spawn in the current zone. It doesnt matter which one. Say you want to spawn another Spawn when a player hails a particular spawn. Here are a few examples:
function hailed(NPC, Spawn)
Spawn(NPC, 4) -- Spawns a new spawn with an id of 4 for all to see
end
function hailed(NPC, Player)
Spawn(Player, 5) -- Spawns a new spawn with an id of 5 for all to see
end
function hailed(CoolNPC, CoolPlayer)
Spawn(CoolNPC, 6) -- Spawns a new spawn with an id of 6 for all to see
end
function hailed(CoolNPC, CoolPlayer)
NewSpawn = Spawn(CoolPlayer, 7, true) -- Spawns a new spawn with an id of 7 that noone can see
AddSpawnAccess(NewSpawn, CoolPlayer) -- give the player access to the private spawn
end
Since the LUA stuff is global, I need a reference to which zone it was called from. That is why the first parameter is a spawn in the current zone. It doesnt matter which one. Say you want to spawn another Spawn when a player hails a particular spawn. Here are a few examples:
function hailed(NPC, Spawn)
Spawn(NPC, 4) -- Spawns a new spawn with an id of 4 for all to see
end
function hailed(NPC, Player)
Spawn(Player, 5) -- Spawns a new spawn with an id of 5 for all to see
end
function hailed(CoolNPC, CoolPlayer)
Spawn(CoolNPC, 6) -- Spawns a new spawn with an id of 6 for all to see
end
function hailed(CoolNPC, CoolPlayer)
NewSpawn = Spawn(CoolPlayer, 7, true) -- Spawns a new spawn with an id of 7 that noone can see
AddSpawnAccess(NewSpawn, CoolPlayer) -- give the player access to the private spawn
end
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
oh btw a safer approach to that last example would be:
function hailed(CoolNPC, CoolPlayer)
NewSpawn = Spawn(CoolPlayer, 7, true) -- Spawns a new spawn with an id of 7 that noone can see
if NewSpawn ~= nil then
AddSpawnAccess(NewSpawn, CoolPlayer) -- give the player access to the private spawn
end
end
The reason being if there is an error and the spawn wasnt spawned for whatever reason like maybe the id was invalid, the previous LUA script would crash.
function hailed(CoolNPC, CoolPlayer)
NewSpawn = Spawn(CoolPlayer, 7, true) -- Spawns a new spawn with an id of 7 that noone can see
if NewSpawn ~= nil then
AddSpawnAccess(NewSpawn, CoolPlayer) -- give the player access to the private spawn
end
end
The reason being if there is an error and the spawn wasnt spawned for whatever reason like maybe the id was invalid, the previous LUA script would crash.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Awesome. Nevermind that first thing in your JA Tasks request then hehe. I'll keep an eye out for commits, and get it to Tess for us to try out. Looks cool.
And speaking of planes - while these days I am crashing networks, once upon a time (10 years ago) I worked for Boeing as well - formerly McDonnell/Douglas Helicopter (Apache/Longbow project) as a network engineer.
And speaking of planes - while these days I am crashing networks, once upon a time (10 years ago) I worked for Boeing as well - formerly McDonnell/Douglas Helicopter (Apache/Longbow project) as a network engineer.
- Scatman
- Retired
- Posts: 1688
- Joined: Wed Apr 16, 2008 5:44 am
- EQ2Emu Server: Scatman's Word
- Characters: Scatman
- Location: New Jersey
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Here's another LUA function that would be popular, especially for getting off the tutorial islands.
ZonePlayer(zone_id|zone_name [x,y,z,h])
...where zone_id|zone_name are either the zone_id or zones.name field from the zones table, and optionally x,y,z,h are the coords to drop the player. If omitted, the zones safe_? coords could be used.
ZonePlayer, or ZoneTarget, ZoneSpawn, whatever you want to name it.
ZonePlayer(zone_id|zone_name [x,y,z,h])
...where zone_id|zone_name are either the zone_id or zones.name field from the zones table, and optionally x,y,z,h are the coords to drop the player. If omitted, the zones safe_? coords could be used.
ZonePlayer, or ZoneTarget, ZoneSpawn, whatever you want to name it.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
OK, I added the GetZone and Zone functions as well as made a few modifications to the Spawn function.
Code: Select all
To get a Zone reference:
Zone = GetZone(name or id or spawn)
To then zone into that zone:
Zone(Zone, Player, x, y, z, h) -- all but Zone and Player are optional
New Spawn parameters are: Spawn(Zone, spawn_id, private_spawn)
Examples:
Zone = GetZone(Spawn)
Spawn(Zone, 4)
Zone = GetZone(Player)
Spawn(Zone, 5, true)
Zone = GetZone(253)
Spawn(Zone, 4)
Zone = GetZone("tutorial_island_good")
Spawn(Zone, 4)
Zone = GetZone(Player)
Zone(Player, 101, 85, 23, 10)
Zone = GetZone(253)
Zone(Player)-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
- Scatman
- Retired
- Posts: 1688
- Joined: Wed Apr 16, 2008 5:44 am
- EQ2Emu Server: Scatman's Word
- Characters: Scatman
- Location: New Jersey
Another LUA function we need is one to be able to tell which step of a certain quest we are on. Like, GetQuestStep(Spawn, quest_id) because sometimes you have to return back to the same quest NPC and each time you return back to him he says something different depending on which step of the quest you are on.
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
LE, are we storing our character_quest and character_quest_progress data yet? If not, can you predict when we might get that? It is not vital for us learning how to write quests, but doing the same steps repeatedly to test new steps will eventually get annoying.
How many waterlogged britches can one man wear?
Thanks
Thanks
Who is online
Users browsing this forum: No registered users and 0 guests