• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

help me with look system/age system

FinalX

New Member
Joined
Nov 27, 2012
Messages
36
Reaction score
2
hello,
i got a problem with a script of mine and i don't know what i did wrong.

the function. must not show the pokemon age if not filled.
and go on to next rule
i know the problem is in look.lua cript only i dont know what i did wrong.
error i got:


Code:
[04/12/2012 14:27:25] [Error - CreatureScript Interface] 
[04/12/2012 14:27:25] data/creaturescripts/scripts/look.lua:onLook
[04/12/2012 14:27:25] Description: 
[04/12/2012 14:27:25] (luaGetItemAttribute) Item not found

[04/12/2012 14:27:25] [Error - CreatureScript Interface] 
[04/12/2012 14:27:25] data/creaturescripts/scripts/look.lua:onLook
[04/12/2012 14:27:25] Description: 
[04/12/2012 14:27:25] data/lib/011-string.lua:16: bad argument #1 to 'find' (string expected, got nil)
[04/12/2012 14:27:25] stack traceback:
[04/12/2012 14:27:25] 	[C]: in function 'find'
[04/12/2012 14:27:25] 	data/lib/011-string.lua:16: in function '(for generator)'
[04/12/2012 14:27:25] 	data/lib/011-string.lua:16: in function 'explode'
[04/12/2012 14:27:25] 	data/lib/age system.lua:2: in function 'getPokemonYears'
[04/12/2012 14:27:25] 	data/lib/age system.lua:38: in function 'getPokemonAge'
[04/12/2012 14:27:25] 	data/creaturescripts/scripts/look.lua:32: in function <data/creaturescripts/scripts/look.lua:1>

lines i wrote:
look.lua
Code:
		 if getItemAttribute(pokeball, "pokeballinfo") then
str = str.."\nIt's "..getPokemonAge(thing.uid).." old."
end

problem directions
011-string.lua rule 16
Code:
string.explode = function (str, sep, limit)
	if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
		return {}
	end

	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
		if(limit ~= nil and i == limit) then
			break
		end
	end

	tmp = str:sub(pos):trim()
	table.insert(t, tmp)
	return t
end

age system: rule 2

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 > ano then years = (12-mes) + monthnow end
return years
end

agesystem.lua rule 38
Code:
function getPokemonAge(pokeball)
return ""..getPokemonYears(pokeball).." year, "..getPokemonMonths(pokeball).." months"
end

- - - Updated - - -

bump
 
Last edited:
Back
Top