• 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 Help random items stats

speery

New Member
Joined
Mar 16, 2017
Messages
26
Reaction score
1
I'm trying to use this random items stats

A edited version of this:
[Mod] Random Item Stats

My edited version:
hastebin

With modification to remove percents sometimes like here in this part:
Code:
                        if n.usePercents then
                            doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))
                        else
                            doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent / 100 .. ']' .. (desc == '' and '' or '\n' .. desc))
                        end

why helmets, legs works
Code:
19:11 You see strong leather legs (Arm:3).
It weighs 18.00 oz.
[Armor: +2]
19:11 You see strong leather legs (Arm:2).
It weighs 18.00 oz.
[Armor: +1]

You see a strong leather helmet (Arm:4).
[Armor: +3]

armors,swords,clubs,axes,boots work with wrong math
Code:
19:13 You see a strong leather armor (Arm:12).
It weighs 60.00 oz.
[Armor: +2]
19:13 You see a strong leather armor (Arm:8).
It weighs 60.00 oz.
[Armor: +1]

19:12 You see a legendary studded club (Atk:9, Def:8 +32).
[Attack Speed: +25%]
[Defense: +4]
19:12 You see a deadly studded club (Atk:9 +27, Def:8).
[Attack: +3]
19:12 You see a fortified studded club (Atk:9, Def:8 +16).
[Defense: +2]
19:12 You see a deadly studded club (Atk:9 +27, Def:8).
[Attack: +3]
19:12 You see a fortified hand axe (Atk:10, Def:4 +8).
[Defense: +2]

19:21 You see strong leather boots (Arm:6).
It weighs 9.00 oz.
[Armor: +1]
19:21 You see strong leather boots (Arm:12).
It weighs 9.00 oz.
[Armor: +3]
19:21 You see legendary leather boots (Arm:15).
It weighs 9.00 oz.
[Armor: +4]

shields just dont work not even enchanting


Anybody know why shield not work and armors,swords,clubs,axes,boots work with wrong math?
 
Last edited:
I can see why your item descriptions don't match the actual values....

fix:
Code:
if n.usePercents then
 doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))
else
 doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. ']' .. (desc == '' and '' or '\n' .. desc))
end

I mean that should be obvious.

Code:
attr['fortified'] = {
   attr = 'extraDefense',
   base = 'defense',
   name = 'Defense',
   percent = {1, 3},
   usePercents = false,
   types = {MELEE, SHIELD}
}

usePercents = false
So you're telling the script, hey don't use percentages for this roll, use static values instead!

Code:
percent = {1, 3},

When this happens, it runs the ELSE block when adding the description:

Code:
doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent / 100 .. ']' .. (desc == '' and '' or '\n' .. desc))

But you're telling it to divide the 1 to 3 value by 100 before printing it on the description.
Derp.​
 
Last edited:
I can see why your item descriptions don't match the actual values....

fix:
Code:
if n.usePercents then
 doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))
else
 doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. ']' .. (desc == '' and '' or '\n' .. desc))
end

I mean that should be obvious.

Code:
attr['fortified'] = {
   attr = 'extraDefense',
   base = 'defense',
   name = 'Defense',
   percent = {1, 3},
   usePercents = false,
   types = {MELEE, SHIELD}
}

usePercents = false
So you're telling the script, hey don't use percentages for this roll, use static values instead!

Code:
percent = {1, 3},

When this happens, it runs the ELSE block when adding the description:

Code:
doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent / 100 .. ']' .. (desc == '' and '' or '\n' .. desc))

But you're telling it to divide the 1 to 3 value by 100 before printing it on the description.
Derp.​

I had tried something like that before, but now, i've tested again with your instructions:
hastebin

Look whats happen when i drop a rare:
Code:
You see a rare hand axe (Atk:10 +30, Def:4 +8).
It weighs 10.00 oz.
[Defense: +200]
[Attack: +300]
 
Back
Top