• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
pbSetSelfSwitchFlexible

v18 pbSetSelfSwitchFlexible 2025-05-08

This resource pertains to version 18 of Pokémon Essentials.
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

first find your Pbset selfswitch code in the script messages near line 333 on V18.1-2
it looks like this
Ruby:
Expand Collapse Copy
 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:
Expand Collapse Copy
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)

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)

now u can do a whole lot more with way less effort!
Credits
InTheLight
Author
InTheLight
Views
482
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from InTheLight

Back
Top