Jump to content

[LUA] Problem with Boss Script

By bizzlesnaff
in Serverside

Recommended Posts

Hi there,

I've tried to bring up the "Eluna Engine" for trinitycore and so far it worked out for me. Now I'm playing around with a few LUA snippets. So far there are 2 different LUA scripts in my folder:
 

local PLAYER_EVENT_ON_LOGIN = 3

local function OnLogin(event, player)
    player:SendBroadcastMessage("I'm online!")
end

RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, OnLogin)

Thats quit easy, and its just for me to be sure LUA is working.

I've tried a little boss script and I dont know whats wrong but nothing happened. Here the code:
 

local NAME = "Elite Boss"
local NPCID = 600000

function Elite_OnCombat(pUnit, event, player)
 Elite=pUnit
 pUnit:SendChatMessage(12, 0, "Hello")
 pUnit:RegisterEvent("Elite_Phase1", 1000, 1)
end

function Elite_OnLeaveCombat(pUnit, event, player)
 pUnit:RemoveEvents() 
 pUnit:SendChatMessage(14, 0, "Bye")
end

function Elite_OnDeath(pUnit, event, player)
 pUnit:RemoveEvents()
end

function Elite_Phase1(pUnit, event, player)
 if Elite:GetHealthPct() == 85 then 
 Elite:SendChatMessage(12, 0, "I see that you want a true battle")
 Elite:CastSpell(52262)
 Elite:RegisterEvent("Elite_Phase2", 1000, 1)
end 
end

RegisterUnitEvent(600000, 1, "Elite_OnCombat")
RegisterUnitEvent(600000, 2, "Elite_OnLeaveCombat")
RegisterUnitEvent(600000, 4, "Elite_OnDeath")

I've just copied this from an online tutorial. The ID 600000 is my testing npc, but he still just hit me without any word :)
The Eluna log told me the folowing things:

 

Quote

2019-02-22_20:57:00 ERROR [Eluna]: Error loading `lua_scripts/firstboss.lua`
2019-02-22_20:57:00 ERROR lua_scripts/firstboss.lua:66: <eof> expected near 'end'
2019-02-22_21:01:50 ERROR [Eluna]: Error loading `lua_scripts/firstboss.lua`
2019-02-22_21:01:50 ERROR lua_scripts/firstboss.lua:66: <eof> expected near 'end'
2019-02-22_21:08:09 ERROR lua_scripts/firstboss.lua:27: attempt to call global 'RegisterUnitEvent' (a nil value)
2019-02-22_21:13:28 ERROR lua_scripts/firstboss.lua:27: attempt to call global 'RegisterUnitEvent' (a nil value)
2019-02-22_21:17:06 ERROR lua_scripts/firstboss.lua:27: attempt to call global 'RegisterUnitEvent' (a nil value)


I'm at the very beginning of LUA, so Ihave no Idea how to fix that. Every little hint would be great.

 

Edit:

Okay, worked out that the second "end" near to the end is without any sense.  But still not workable.

Link to comment
Share on other sites

7 hours ago, bizzlesnaff said:

Okay, worked out that the second "end" near to the end is without any sense.  But still not workable.

You need two ends for the last function because you have a if statement in the function as well. I see your eluna is erroring that you need a end near <eof> but all your ends look fine to me, is there more the the script?

 

7 hours ago, bizzlesnaff said:

RegisterUnitEvent(600000, 1, "Elite_OnCombat") RegisterUnitEvent(600000, 2, "Elite_OnLeaveCombat") RegisterUnitEvent(600000, 4, "Elite_OnDeath")

In Arcemu you needed to use "" in your hooks to register them but you don't need to do that in Eluna, remove the "" and just have RegisterUnitEvent(600000, 1, Elite_OnCombat)

 pUnit:RegisterEvent("Elite_Phase1", 1000, 1)
function Elite_Phase1(pUnit, event, player)

Once again remove the "" and in addition your parameters are incorrect, they should be (eventId, delay, repeats, worldobject). More information can be found here regarding everything eluna http://www.elunaengine.com/WorldObject/RegisterEvent.html.

Link to comment
Share on other sites

×
×
  • Create New...