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:49] vodurlua:scripting:examples:olcscripts [2016/10/02 03:26] (current) – [Reduce wealth of shops over 100%] vodur
Line 1: Line 1:
-====== Various OLC scripts ======+====== OLC scripts ======
  
 ===== Edit all wands and staffs to have 50/50 charges ===== ===== Edit all wands and staffs to have 50/50 charges =====
Line 90: Line 90:
  
 <code lua> <code lua>
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>do</font> +do 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local area=getroom(2031).area</font>+local area=getroom(2031).area
  
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>for _,room in pairs(area.rooms) do</font> +for _,room in pairs(area.rooms) do 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local edited=false</font> +    local edited=false 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>clearloopcount()</font> +    clearloopcount() 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local finished</font> +    local finished 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>while not finished do</font> +    while not finished do 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>finished=true</font> +        finished=true 
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local num_resets=#room.resets</font> +        local num_resets=#room.resets
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);></font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>for i,reset in ipairs(room.resets) do</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>if reset.command=="M" then</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>goto(room.vnum)</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local rmax=reset.arg4</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local amax=reset.arg2</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local mvnum=reset.arg1</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);></font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>if amax>25 then</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>local newmax=25</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>rmax=math.min(rmax,newmax)</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>--local newmax=math.max(20, amax/2)</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>--newmax=math.min(amax, 50)</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>edited=true</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>mdo("reset "..i.." delete")</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>mdo("reset "..num_resets.." mob "..mvnum.." "..newmax.." "..rmax)</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>finished=false</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>break</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>end</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>end</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>end</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>end</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>if edited then mdo('reset') end</font> +
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco, ;;inherit;;rgb(46, 139, 87) font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 11.6999998092651px; line-height: 15.210000038147px; background-color: rgb(255, 255, 255);>end</font>+
  
-<font 11.6999998092651px line-height: 15.210000038147px; background-color: rgb(255, 255, 255);/Monaco;;inherit;;rgb(46139, 87font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size11.6999998092651px; line-height15.210000038147px; background-color: rgb(255255255);>end</font>+        for i,reset in ipairs(room.resets) do 
 +            if reset.command=="M" then 
 +                goto(room.vnum) 
 +                local rmax=reset.arg4 
 +                local amax=reset.arg2 
 +                local mvnum=reset.arg1 
 + 
 +                if amax>25 then 
 +                    local newmax=25 
 +                    rmax=math.min(rmax,newmax) 
 +                    --local newmax=math.max(20amax/2) 
 +                        --newmax=math.min(amax50) 
 +                    edited=true 
 +                    mdo("reset "..i.." delete"
 +                    mdo("reset "..num_resets.." mob "..mvnum.." "..newmax.." "..rmax) 
 +                    finished=false 
 +                    break 
 +                end 
 +            end 
 +        end 
 +    end 
 +    if edited then mdo('reset') 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
 </code> </code>
  
lua/scripting/examples/olcscripts.1426463375.txt.gz · Last modified: 2015/03/15 23:49 by vodur