T
Tibia Demon
Guest
Is there any difference in performance if I have my script tabled like this
or having it in separated Lua files like this
Will there be any noticeable performance difference?
Lua:
local items = {
[5903] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_HITBYPOISON, textTwo = "Hell", monsterx = "orshabaal", money = 8000},
[4851] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_CAKE, textTwo = "fire", monsterx = "Demon", money = 5000},
[2062] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_SOUND_RED, textTwo = "dragon", monsterx = "dragon lord", money = 1500},
[2073] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_MORTAREA, textTwo = "boss", monsterx = "morgaroth", money = 3000},
[7487] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_HITBYFIRE, textTwo = "dragon", monsterx = "dragon", money = 2500},
[5791] = {text = "Summoned", effect = CONST_ME_HOLYAREA, effectTwo = CONST_ME_EXPLOSIONHIT, textTwo = "cyclops!!", monsterx = "cyclops", money = 1000}
}
local summonItemx = Action()
function summonItemx.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local summonItemx = items[item.itemid]
local SummonItem = items[item.itemid]
if SummonItem and player:removeTotalMoney(SummonItem.money) then
player:say(SummonItem.text, TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(SummonItem.effect)
Game.createMonster(SummonItem.monsterx, player:getPosition())
else
player:getPosition():sendMagicEffect(SummonItem.effectTwo)
player:say(SummonItem.textTwo, TALKTYPE_MONSTER_SAY)
end
return true
end
for k, v in pairs(items) do
summonItemx:id(k)
end
summonItemx:register()
Lua:
local orshabaal = Action()
local money = 1000
function orshabaal.onUse(player, item, fromPos, target, toPos, isHotkey)
if player:removeTotalMoney(money) then
Game.createMonster("orshabaal", player:getPosition())
player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
else
player:say('hell', TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
return true
end
orshabaal:id(6546)
orshabaal:register()
Lua:
local demon = Action()
local money = 100
function demon.onUse(player, item, fromPos, target, toPos, isHotkey)
if player:removeTotalMoney(money) then
Game.createMonster("demon", player:getPosition())
player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
else
player:say('demon summoned', TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
return true
end
demon:id(6545)
demon:register()