• 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!

Lua Function on look.

Il Knight

Veteran OT User
Joined
Dec 1, 2014
Messages
676
Solutions
7
Reaction score
350
Location
Spain
Hello otland!
today im trying to do a function on look.

Lua:
function Player:onLook(thing, position, distance)
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

How i can get the Type, Min damage, And Max damage of a wand?
i wanna display on the Look (only for wands) Something like =

XML:
<wand id="23719" level="1" mana="1" min="20" max="50" type="fire"> <!-- The Scorcher -->
    <vocation name="Sorcerer" />
</wand>

You see a wand.
Damage 20-50.
Element fire.
only properly etc etc

thanks in advance
 
Last edited by a moderator:
That's why I use as little xml as possible.

If you still insist of using xml and adding features there, then like xeraphus stated you can parse the xml file into lua table when server starts up.
Code:
local f = io.open("data/weapons/weapons.xml", "rb")
    local content = f:read("*all")
    f:close()
I believe you know how to handle the rest from here.
 
Thanks guys but i find other way more easy
on items xml

<attribute key="defense" value="22" />
<attribute key="attack" value="45" />

Where attack = (max attack)
defense = (Min attack)

function Player:eek:nLook(thing, position, distance)

if thing is wand or rod =

You see + name +Max attack, Min attack+ weight + id + position.
 
Thanks guys but i find other way more easy
on items xml

<attribute key="defense" value="22" />
<attribute key="attack" value="45" />

Where attack = (max attack)
defense = (Min attack)

function Player:eek:nLook(thing, position, distance)

if thing is wand or rod =

You see + name +Max attack, Min attack+ weight + id + position.
Yeah, but now, your wands would have attack and defense attributes...
It's better idea to create a table like guys above said.
 
Im not saying to that you cant use xml. I gave you solution how any of those custom attributes will be easy to read. If you have done string matching correctly
 
Back
Top