I'm trying to use the following code as a script.lua for a talkaction to simulate a new "summon creature" spell, but trying to run my server this error message appears in console:
Description:
[9:26:49.447] data/talkactions/scripts/callofnature1.lua:33: bad argument #1 to 'lower' (string expected, got nil)
Anyone knows how to solve this problem or even know a proper system to create a new summon creature spell? Thanks!
Code:
Description:
[9:26:49.447] data/talkactions/scripts/callofnature1.lua:33: bad argument #1 to 'lower' (string expected, got nil)
Anyone knows how to solve this problem or even know a proper system to create a new summon creature spell? Thanks!
Code:
Lua:
-- General Configuration
local lvlmin = 1
local exhaustion = 3000
local needlearn = 1
local learnstorage = 77890
local vocations = {2, 3}
local maxsummons = getConfigValue("maxPlayerSummons")
summonlist = {
[1] = {'rat', 4},
[2] = {'bat', 4},
[3] = {'bug', 4},
[4] = {'snake', 4}
}
-- Player Info
local lvl = getPlayerLevel(cid)
local vocp = getPlayerVocation(cid)
local mana = getCreatureMana(cid)
local pos = getCreaturePosition(cid)
-- Statements
local learned = 0
local voccan = 0
local cansummon = 0
local manacost = 0
local exhaustorage = 77889
-- Loop Control
local vocs = #vocations
local slistn = #summonlist
-- Conversions
param = string.lower(param)
param = string.gsub(param, '\"', '')
exhaustion = exhaustion/1000
-- Initial Verification
if needlearn == 0 then learned = 1 end
if needlearn == 1 and getPlayerStorageValue(cid, learnstorage) > 0 then learned = 1 end
while vocs > 0 do
if vocp == vocations[vocs] then voccan = 1 end
vocs = vocs - 1
end
while slistn > 0 do
if param == summonlist[slistn][1] then
cansummon = 1
manacost = summonlist[slistn][2]
end
slistn = slistn - 1
end
-- Summon Monster
if getTilePzInfo(pos) then
doPlayerSendCancel(cid, 'This action is not permitted in a protection zone.')
else
if lvl < lvlmin then
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'You do not have enough level.')
else
if learned == 1 then
if voccan == 1 then
if getPlayerStorageValue(cid, exhaustorage) >= os.time() then
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'You are exhausted.')
else
if cansummon == 1 then
if mana >= manacost then
if #getCreatureSummons(cid) < maxsummons then
doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
doCreatureAddMana(cid, 0-manacost, false)
local summon = doCreateMonster(param, pos)
doConvinceCreature(cid, summon)
doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
setPlayerStorageValue(cid, exhaustorage, os.time()+exhaustion)
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'You cannot summon more creatures.')
end
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'You do not have enough mana.')
end
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'Sorry, not possible.')
end
end
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'Your vocation cannot use this spell.')
end
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, 'You need to learn this spell first.')
end
end
end
return
Last edited: