User Tools

Site Tools


lua:scripting:examples:olcscripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lua:scripting:examples:olcscripts [2015/03/15 23:51] vodurlua:scripting:examples:olcscripts [2016/10/02 03:26] (current) – [Reduce wealth of shops over 100%] vodur
Line 125: Line 125:
 end end
  
 +end
 +</code>
 +===== Burnproof flag removal / Nonmetal Weapon adjust =====
 +
 +<code lua>
 +function anti_burnproof()
 +    local count = 0
 +    for _,area in pairs(getarealist()) do
 +        if not area:flag("clone") then
 +            for _,op in pairs(area.objprotos) do
 +                if op:extra("burnproof") and (op.otype == "armor" or op.otype == "weapon") then
 +                    -- adjust damage using olc
 +                    mdo("oedit " .. op.vnum)
 +                    olc("extra burnproof")
 +                    olc("done")
 +                    count = count + 1
 +                end
 +            end
 +        end
 +    end
 +    sendtochar(mob, "Removed burnproof flag from " .. count .. " items.\n")
 +end
 +
 +function nonmetal_weapons()
 +    local count = 0
 +    for _,area in pairs(getarealist()) do
 +        if not area:flag("clone") then
 +            for _,op in pairs(area.objprotos) do
 +                if op:extra("nonmetal") and op.otype == "weapon" and op.level>= 1 and op.level <= 100 then
 +                    -- remove burnproof flag using olc
 +                    mdo("oedit " .. op.vnum)
 +                    olc("adjust")
 +                    olc("done")
 +                    count = count + 1
 +                end
 +            end
 +        end
 +    end
 +    sendtochar(mob, "Adjusted damage for " .. count .. " nonmetal weapons.\n")
 +end
 +</code>
 +===== Reduce wealth of shops over 100% =====
 +
 +<code lua>
 +do
 +
 +local cnt = 0
 +
 +for _,area in pairs(getarealist()) do
 +    for _,mp in pairs(area.mobprotos) do
 +        if mp.shop and mp.wealthpcnt> 100 then
 +            mdo("medit "..mp.vnum)
 +            olc("wealth 100")
 +            olc('done')
 +            cnt = cnt + 1
 +
 +        end
 +    end
 +end
 +local msg = "Updated wealth on "..cnt.." mobs via lua script"
 +log(msg, 'secure')
 end end
 </code> </code>
  
lua/scripting/examples/olcscripts.1426463515.txt.gz · Last modified: 2015/03/15 23:51 by vodur