Im tired of setting 20 self switches to true or false in 1 event action for instance you can choos 1 item on the ground and after that the other 10 set self switch a to true preventing you fro getting them so you have to do this
pbSetSelfSwitch(1,"A",true)
pbSetSelfSwitch(2,"A",true)
....
pbSetSelfSwitch(9,"A",true)
pbSetSelfSwitch(10,"A",true)
this is annoying so I created: pbSetSelfSwitchFlexible
Now when you call it you can insert a range of switches (and it can be any map)
now events can take just 1 number or a range of numbers and it will look like this
now u can do a whole lot more with way less effort!
pbSetSelfSwitch(1,"A",true)
pbSetSelfSwitch(2,"A",true)
....
pbSetSelfSwitch(9,"A",true)
pbSetSelfSwitch(10,"A",true)
this is annoying so I created: pbSetSelfSwitchFlexible
first find your Pbset selfswitch code in the script messages near line 333 on V18.1-2
it looks like this
now right below it put this
it looks like this
Ruby:
def pbSetSelfSwitch(event,swtch,value,mapid=-1)
mapid = @map_id if mapid<0
oldValue = $game_self_switches[[mapid,event,swtch]]
$game_self_switches[[mapid,event,swtch]] = value
if value!=oldValue && $MapFactory.hasMap?(mapid)
$MapFactory.getMap(mapid,false).need_refresh = true
end
end
now right below it put this
Code:
def pbSetSelfSwitchFlexible(map_id, events, switch, value)
event_ids = []
[*events].each do |entry|
if entry.is_a?(Range)
event_ids.concat(entry.to_a)
else
event_ids << entry
end
end
event_ids.each do |event_id|
$game_self_switches[[map_id, event_id, switch]] = value
end
$game_map.need_refresh = true if $game_map.map_id == map_id
end
Now when you call it you can insert a range of switches (and it can be any map)
so in an event call it by Insert>Script> then type it out like u would with the original
"pbSetSelfSwitchFlexible( map_id, events, switch, value )"
Map_id = map number
Events = which events you want to switch
Switch = (A,B,C,D)
Value = (true or false)
"pbSetSelfSwitchFlexible( map_id, events, switch, value )"
Map_id = map number
Events = which events you want to switch
Switch = (A,B,C,D)
Value = (true or false)
now events can take just 1 number or a range of numbers and it will look like this
Range:
pbSetSelfSwitchFlexible(309, 1..10,, 'A', true) - this is for events 1-10
single number:
pbSetSelfSwitchFlexible(309, 13, 'A', true) - pretty much the same as original but with map id
Range with number out of range:
pbSetSelfSwitchFlexible(309, [1..10, 13], 'A', true)
it can go even further:
pbSetSelfSwitchFlexible(309, [1..5, 7, 9..12], 'A', true)
pbSetSelfSwitchFlexible(309, 1..10,, 'A', true) - this is for events 1-10
single number:
pbSetSelfSwitchFlexible(309, 13, 'A', true) - pretty much the same as original but with map id
Range with number out of range:
pbSetSelfSwitchFlexible(309, [1..10, 13], 'A', true)
it can go even further:
pbSetSelfSwitchFlexible(309, [1..5, 7, 9..12], 'A', true)
now u can do a whole lot more with way less effort!
- Credits
- InTheLight