lua:scripting:examples:olcscripts
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| lua:scripting:examples:olcscripts [2015/03/15 08:52] – created vodur | lua:scripting:examples:olcscripts [2016/10/02 03:26] (current) – [Reduce wealth of shops over 100%] vodur | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Edit v1 and v2 values for all wands and staffs | + | ====== OLC scripts ====== |
| + | |||
| + | ===== Edit all wands and staffs | ||
| <code lua> | <code lua> | ||
| do | do | ||
| - | local function menu_handler( ch ) | + | for _,area in pairs(getarealist()) do |
| - | | + | |
| + | if op.otype=="wand" or op.otype=="wand" then | ||
| + | if not(op.chargesleft==50) or not(op.chargestotal==50) then | ||
| + | mdo(" | ||
| + | olc(" | ||
| + | olc(" | ||
| + | olc(" | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | end | ||
| - | while true do | + | end |
| - | | + | </ |
| - | [s]ex | + | |
| - | [r]ace | + | |
| - | [c]lass | + | |
| - | [q]uit | + | |
| - | ]]) | + | |
| - | local cmd=coroutine.yield() | + | |
| - | if cmd==" | + | ===== Shop wands/ |
| - | | + | |
| - | | + | -1 makes the # of charges randomize |
| - | | + | |
| - | elseif | + | <code lua> |
| - | | + | do |
| - | elseif cmd=="q" then | + | |
| - | | + | local cnter=0 |
| - | else | + | local reset_check = {} |
| - | | + | for _,area in pairs(getarealist()) do |
| + | for _,room in pairs(area.rooms) do | ||
| + | local shop=false | ||
| + | | ||
| + | | ||
| + | local cmd=reset.command | ||
| + | |||
| + | if cmd == "M" then | ||
| + | |||
| + | if getmobproto(reset.arg1).shop then | ||
| + | | ||
| + | |||
| + | else | ||
| + | shop=false | ||
| + | |||
| + | end | ||
| + | | ||
| + | |||
| + | if shop==true then | ||
| + | | ||
| + | elseif reset_check[reset.arg1]==nil then | ||
| + | reset_check[reset.arg1]=false | ||
| + | end | ||
| + | end | ||
| + | end | ||
| end | end | ||
| end | end | ||
| - | end | ||
| - | start_con_handler( mob.descriptor, menu_handler, | + | for _,area in pairs(getarealist()) do |
| + | for _,op in pairs(area.objprotos) do | ||
| + | if op.otype==" | ||
| + | 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(" | ||
| + | olc(" | ||
| + | olc(" | ||
| + | olc(" | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | end | ||
| end | end | ||
| </ | </ | ||
| - | < | + | ===== Surreal reset culling ===== |
| - | Beginning the menu test. | + | |
| - | [s]ex | + | [[http:// |
| - | [r]ace | + | |
| - | [c]lass | + | < |
| - | [q]uit | + | do |
| - | s | + | local area=getroom(2031).area |
| - | Your sex: male | + | |
| - | [s]ex | + | for _,room in pairs(area.rooms) do |
| - | [r]ace | + | local edited=false |
| - | [c]lass | + | |
| - | [q]uit | + | local finished |
| - | r | + | while not finished do |
| - | Your race: wraith | + | |
| - | [s]ex | + | local num_resets=# |
| - | [r]ace | + | |
| - | [c]lass | + | for i,reset in ipairs(room.resets) do |
| - | [q]uit | + | if reset.command==" |
| - | c | + | |
| - | Your class: illusionist | + | local rmax=reset.arg4 |
| - | [s]ex | + | local amax=reset.arg2 |
| - | [r]ace | + | local mvnum=reset.arg1 |
| - | [c]lass | + | |
| - | [q]uit | + | if amax>25 then |
| - | q | + | local newmax=25 |
| - | lua> | + | rmax=math.min(rmax, |
| + | --local newmax=math.max(20, | ||
| + | --newmax=math.min(amax, | ||
| + | edited=true | ||
| + | mdo(" | ||
| + | mdo(" | ||
| + | finished=false | ||
| + | break | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | if edited then mdo(' | ||
| + | end | ||
| + | |||
| + | end | ||
| + | </ | ||
| + | ===== Burnproof flag removal / Nonmetal Weapon adjust ===== | ||
| + | |||
| + | <code lua> | ||
| + | function anti_burnproof() | ||
| + | local count = 0 | ||
| + | for _,area in pairs(getarealist()) do | ||
| + | if not area:flag(" | ||
| + | for _,op in pairs(area.objprotos) do | ||
| + | if op: | ||
| + | -- adjust damage using olc | ||
| + | | ||
| + | olc(" | ||
| + | olc(" | ||
| + | count = count + 1 | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | sendtochar(mob, | ||
| + | end | ||
| + | |||
| + | function nonmetal_weapons() | ||
| + | local count = 0 | ||
| + | for _,area in pairs(getarealist()) do | ||
| + | if not area:flag(" | ||
| + | for _,op in pairs(area.objprotos) do | ||
| + | if op: | ||
| + | -- remove burnproof flag using olc | ||
| + | | ||
| + | | ||
| + | | ||
| + | count = count + 1 | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | end | ||
| + | sendtochar(mob, | ||
| + | end | ||
| + | </ | ||
| + | ===== Reduce wealth of shops over 100% ===== | ||
| + | |||
| + | < | ||
| + | do | ||
| + | |||
| + | local cnt = 0 | ||
| + | |||
| + | for _,area in pairs(getarealist()) do | ||
| + | for _,mp in pairs(area.mobprotos) do | ||
| + | if mp.shop and mp.wealthpcnt> | ||
| + | mdo(" | ||
| + | olc(" | ||
| + | olc(' | ||
| + | cnt = cnt + 1 | ||
| + | |||
| + | end | ||
| + | end | ||
| + | end | ||
| + | local msg = " | ||
| + | log(msg, ' | ||
| + | end | ||
| </ | </ | ||
lua/scripting/examples/olcscripts.1426409575.txt.gz · Last modified: 2015/03/15 08:52 by vodur