• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [help]get something in item description

Exedion

Active Member
Joined
Jun 11, 2007
Messages
629
Reaction score
30
i try to get a number in a item description, but i don't know well how do this, take a look of the item desc:


14:45 You see a Rat sealed rune.
It weighs 1.20 oz.
Health:[5/20]
It master is Test.

i try to return the number "5" and "20" from this desc using:
LUA:
	local desc = getItemAttribute(item.uid, "description")
	local l_health = desc:match('Health:(%[%.-)')
	local m_health = desc:match('/(.+)]')

but i get this error:
Code:
[14:27:27.097] [Error - Action Interface]
[14:27:27.097] data/actions/scripts/goback.lua:onUse
[14:27:27.099] Description:
[14:27:27.099] data/actions/scripts/goback.lua:35: attempt to perform arithmetic
 on local 'l_health' (a string value)
[14:27:27.100] stack traceback:
[14:27:27.101]  data/actions/scripts/goback.lua:35: in function <data/actions/sc
ripts/goback.lua:1>

can help me PLEASEEE!!
 
LUA:
 local desc = getItemAttribute(item.uid, "description")
local a, b = desc:find('Health:')
local hp = desc:sub(b+2, tmp:find('/', b)-1)
Noob method, but works.
 
Back
Top