Oneda
Aspiring Spriter
So, I'm trying to parse a var in a getItemCount, but its returning nil, not really sure what I'm doing wrong here.
if I replace
with
for example, the script runs well. Pretty confused why the var itself is returning nil.
Edit: nevermind, I actually just re-read the post and found the obvious mistake.
The solution if anyone else ever make this mistake:
and
(Yeah, just converting the var back into a number.)
if I replace
Lua:
player:getItemCount(aucItem)
Lua:
player:getItemCount(2160)
Lua:
function onSay(player, words, param)
local aucItem = param
if not tonumber(aucItem) then
player:sendPrivateMessage(player, "Invalid item ID.")
print (''..aucItem..'[1]')
elseif player:getItemCount(aucItem) <= 0 then
print (''..aucItem..'[2]')
player:sendPrivateMessage(player, "You don't have any items with that ID.")
else
print (''..aucItem..'[3]')
end
end
Edit: nevermind, I actually just re-read the post and found the obvious mistake.
The solution if anyone else ever make this mistake:
Lua:
local aucItem = tonumber(param)
Lua:
if not tonumber(param) then
(Yeah, just converting the var back into a number.)
Last edited: