User Tools

Site Tools


lua:scripting:examples:olcscripts

This is an old revision of the document!


Various OLC scripts

Edit all wands and staffs to have 50/50 charges

do
 
for _,area in pairs(getarealist()) do
    for _,op in pairs(area.objprotos) do
        if op.otype=="wand" or op.otype=="wand" then
            if not(op.chargesleft==50) or not(op.chargestotal==50) then
                mdo("oedit "..op.vnum)
                olc("v1 50")
                olc("v2 50")
                olc("done")
            end
        end
    end
end
 
end

Shop wands/staffs have 50/50 charges, otherwise set to -1/50

-1 makes the # of charges randomize then item pops.

do
 
    local cnter=0
    local reset_check = {}
    for _,area in pairs(getarealist()) do
        for _,room in pairs(area.rooms) do
            local shop=false
            for i,reset in ipairs(room.resets) do
                clearloopcount()
                local cmd=reset.command
 
                if cmd == "M" then
 
                    if getmobproto(reset.arg1).shop then
                        shop=true
 
                    else
                        shop=false
 
                    end
                elseif cmd == "G" then
 
                    if shop==true then
                        reset_check[reset.arg1]=true
                    elseif reset_check[reset.arg1]==nil then
                        reset_check[reset.arg1]=false
                    end
                end
            end
        end
    end
 
    for _,area in pairs(getarealist()) do
        for _,op in pairs(area.objprotos) do
            if op.otype=="wand" or op.otype=="staff" then
                local chargesleft_target
                local chargestotal_target
                if reset_check[op.vnum]==true then
                    chargesleft_target=50
                    chargestotal_target=50
                else
                    chargesleft_target=-1
                    chargestotal_target=50
                end
 
                if not(op.chargesleft==chargesleft_target) or not(op.chargestotal==chargestotal_target) then
                    mdo("oedit "..op.vnum)
                    olc("v1 "..chargestotal_target)
                    olc("v2 "..chargesleft_target)
                    olc("done")
                end
            end
        end
    end
 
end

Surreal reset culling

http://aarchonmud.com/forum/viewtopic.php?f=25&t=242

<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>
<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>
 
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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(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>
lua/scripting/examples/olcscripts.1426463375.txt.gz · Last modified: 2015/03/15 23:49 by vodur