Vendily

Lights Out and Multi Button Puzzle Methods

Sep 26th, 2025 (edited)
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.25 KB | None | 0 0
  1. class Interpreter
  2.   def pbToggleSelfSwitch(event,swtch,mapid=-1)
  3.     mapid = @map_id if mapid<0
  4.     $game_self_switches[[mapid,event,swtch]] = !$game_self_switches[[mapid,event,swtch]]
  5.     if $map_factory.hasMap?(mapid)
  6.       $map_factory.getMap(mapid, false).need_refresh = true
  7.     end
  8.   end
  9. end
  10.  
  11. def lo_switch_toggle(*event_ids)
  12.   event_ids.each do |id|
  13.     pbToggleSelfSwitch(id,"A")
  14.   end
  15. end
  16.  
  17. def lo_check_puzzle(solution,*event_ids)
  18.   raise "mismatch in events and solution length" if solution.length != event_ids.length
  19.   solved = true
  20.   solution.each_char.with_index do |s,i|
  21.     e = $game_map.events[event_ids[i]]
  22.     case s
  23.     when "0"
  24.       if e.isOn?("A")
  25.         solved = false
  26.         break
  27.       end
  28.     when "1"
  29.       if e.isOff?("A")
  30.         solved = false
  31.         break
  32.       end
  33.     end
  34.   end
  35.   return solved
  36. end
  37.  
  38. def check_boulder_puzzle(event_ids, *button_pos)
  39.   used_buttons = []
  40.   event_ids.each do |id|
  41.     event = $game_map.events[id]
  42.     next if !event
  43.     button_pos.each_with_index do |button, idx|
  44.       next if used_buttons.include?(idx)
  45.       next unless event.x == button[0] && event.y == button[1]
  46.       used_buttons.push(idx)
  47.     end
  48.   end
  49.   return used_buttons.length == button_pos.length
  50. end
Advertisement
Add Comment
Please, Sign In to add comment