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

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 05:02 PM.


 

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