LUA Functions Request

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

Moderator: Team Members

Post Reply
LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Aug 29, 2008 1:43 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

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Aug 29, 2008 1:47 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.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Aug 29, 2008 1:51 pm

Ok cool so I can give the "Spawn" param the questgiver parameter passed in through a quest script. Easy enough :)
Thanks!

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Fri Aug 29, 2008 3:59 pm

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.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Aug 29, 2008 8:26 pm

I just thought of another one but I'm not even sure if it's possible yet. We need a questUpdate function to allow us to update quests after inspecting a certain item (or reading a book). One of the quests on the noobie island requires this so that's when it came to mind.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Aug 30, 2008 8:11 am

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.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Aug 30, 2008 10:18 am

And yet another! :)
SpawnAnim(visual_state_id) or SpawnEmote(visual_state_id, text) something like that. Unless there is already a function for this in the Play* stuff, which I haven't figured out yet.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Aug 30, 2008 11:45 am

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)

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Aug 30, 2008 11:48 am

Sweet! Thanks LE.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Aug 30, 2008 12:08 pm

Bah, I just realized that I didn't add any parameters to tell it WHERE you wanted to spawn the spawn. heh Anyways, I'll add x, y, z, heading to the function with heading being optional.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Aug 30, 2008 12:16 pm

Lol, we all have our brain farts :P

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Aug 30, 2008 2:17 pm

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

Post by LethalEncounter » Sat Aug 30, 2008 2:38 pm

OK, I added it as GetQuestStep(Player, quest_id). It returns 0 if the player doesnt have the quest, or the last completed step + 1.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Aug 30, 2008 2:43 pm

Perfect, thanks!

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Aug 30, 2008 2:46 pm

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. :D How many waterlogged britches can one man wear?
Thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests