Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

Reply
 
Thread Tools Display Modes
  #1  
Old 04-09-2016, 10:39 AM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default Lua: Getting qglobals in event_death_complete

Wondering if anyone can assist with this. I have a default.pl quest set to assign a quest global credit when a mob is killed in a zone. The zones i am using it in (Befallen & Crushbone) also have a lot of .lua scripts already created so I am trying to convert this section to lua as well so I can copy/paste it into the other scripts.

Perl quest:
Code:
sub EVENT_DEATH_COMPLETE {
#Prevent pets or charmed NPCs from loading the default.pl
	if (!$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner())
	{
		return;
	}

#Checking if the reborn_credits global is defined for this character
    if (defined ($client->GetGlobal("reborn_credits"))) {
#Adding 1 point/credit to the reborn_credits global
		my $total = $client->GetGlobal("reborn_credits");
		$total += 1;
		$client->SetGlobal("reborn_credits", $total, 5, "F");
		$client->Message(5, "You have gained a Reborn armor credit! You currently have $total.");
    }
}
This is what I have so far for the Lua version, however GetGlobal is always returning "Undefined". SetGlobal works fine, it's only commented out for the moment because it is just setting the qglobal to 0 over and over.
Code:
function event_death_complete(e)
	local total = 0;
	if(e.other:GetGlobal("reborn_credits") ~= "Undefined") then
		total = tonumber(e.other:GetGlobal("reborn_credits"));
	end
--	total = total + 1;
--	e.other:SetGlobal("reborn_credits", tostring(total), 5, "F");
	e.other:Message(5, "You have gained a Reborn armor credit! You currently have "..total..".");
end
Reply With Quote
  #2  
Old 04-09-2016, 09:23 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I had crazy absent minded drivel here.
Reply With Quote
  #3  
Old 04-09-2016, 10:12 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

This is lua Ghanja not perl
Reply With Quote
  #4  
Old 04-09-2016, 10:15 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by NatedogEZ View Post
This is lua Ghanja not perl
Ohhh, yeah ok, I see what I did there now. Welp, going back to the Perl forums where I should stay then. :p
Reply With Quote
  #5  
Old 04-09-2016, 10:30 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

I would suggest using `event_killed_merit` BTW!

Code:
function event_killed_merit(e)
	local total = 0;
	local qglobals = eq.get_qglobals(e.other);
	if (qglobals["reborn_credits"] == nil) then
		total = 1;
	else
		total = tonumber(qglobals["reborn_credits"]) + 1;
	end

	e.other:SetGlobal("reborn_credits", tostring(total), 5, "F");
	e.other:Message(5, "You have gained a Reborn armor credit! You currently have "..total..".");
end
Reply With Quote
  #6  
Old 04-10-2016, 07:50 PM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default

Perfect, many thanks NatedogEZ!

Will give this a go tonight. I did use event_killed_merit in my perl example but couldn't get it to work (think I was using the old qglobal{} method instead of $client->) and eventually swapped over to death_complete. Just never swapped back after working it all out.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:00 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3