Note that there are some explanatory texts on larger screens.

plurals
  1. POLua error: string expected, got nil
    primarykey
    data
    text
    <p>I need help with my scripts. I tried nearly everything, but I can't figure it out what the problem is. I want <code>look.lua</code> to check if <code>str = str.."\nIt's "..getPokemonAge(thing.uid).." old."</code> Returns with nil, then ignores it and goes on with the script.</p> <p>This is the error I get on console:</p> <pre><code>[04/12/2012 20:43:42] [Error - CreatureScript Interface] [04/12/2012 20:43:42] data/creaturescripts/scripts/look.lua:onLook [04/12/2012 20:43:42] Description: [04/12/2012 20:43:42] data/lib/011-string.lua:16: bad argument #1 to 'find' (string expected, got nil) [04/12/2012 20:43:42] stack traceback: [04/12/2012 20:43:42] [C]: in function 'find' [04/12/2012 20:43:42] data/lib/011-string.lua:16: in function '(for generator)' [04/12/2012 20:43:42] data/lib/011-string.lua:16: in function 'explode' [04/12/2012 20:43:42] data/lib/age system.lua:2: in function 'getPokemonYears' [04/12/2012 20:43:42] data/lib/age system.lua:42: in function 'getPokemonAge' [04/12/2012 20:43:42] data/creaturescripts/scripts/look.lua:32: in function &lt;data/creaturescripts/scripts/look.lua:1&gt; </code></pre> <p>011-string.lua</p> <pre><code>local i, pos, tmp, t = 0, 1, "", {} for s, e in function() return string.find(str, sep, pos) end do tmp = str:sub(pos, s - 1):trim() table.insert(t, tmp) pos = e + 1 i = i + 1 end </code></pre> <p>look.lua</p> <pre><code>str = str.."\nIt's "..getPokemonAge(thing.uid).." old." </code></pre> <p>age system.lua</p> <pre><code>function getPokemonYears(pokeball) local data = string.explode(getItemAttribute(pokeball, "pokeballinfo"), "/") -- data[1] = dia, data[2] = mes, data[3] = ano local yearnow = math.floor(tonumber(os.date("%Y"))) local monthnow = math.floor(tonumber(os.date("%m"))) local daynow = math.floor(tonumber(os.date("%d"))) local ano = math.floor(tonumber(data[3])) local mes = math.floor(tonumber(data[2])) local dia = math.floor(tonumber(data[1])) local years = 0 if yearnow == ano then years = monthnow-mes end if yearnow &gt; ano then years = (12-mes) + monthnow end return years end function getPokemonMonths(pokeball) local data = string.explode(getItemAttribute(pokeball, "pokeballinfo"), "/") local yearnow = math.floor(tonumber(os.date("%Y"))) local monthnow = math.floor(tonumber(os.date("%m"))) local daynow = math.floor(tonumber(os.date("%d"))) local ano = math.floor(tonumber(data[3])) local mes = math.floor(tonumber(data[2])) local dia = math.floor(tonumber(data[1])) if (yearnow == ano) and (monthnow==mes) and (daynow&lt;dia+2.5) then months = 0 end if (yearnow == ano) and (monthnow==mes) and (daynow&gt;dia+2.5) then months = (daynow-dia)/2.5 end if (yearnow == ano) and (monthnow&gt;mes) then months = math.floor((30-dia)/2.5) + daynow/2.5 end if (yearnow &gt; ano) then days = math.floor(monthnow*30+daynow) months = math.floor(days/2.5) end if tostring(months):len() &gt; 3 then months2 = tonumber(string.sub(tostring(months), 1, 3)) else months2 = months end return months end function getPokemonAge(pokeball) return ""..getPokemonYears(pokeball).." year, "..getPokemonMonths(pokeball).." months" end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload