I'm trying to turn on a switch using RGSS. It looks like its turned on properly when I test it (p $game_switches[switch_id]) but it doesn't work in-game. I've tried adding '$game_switches = Game_Switches.new' before it and it didn't help.
This is the class its in, I'm also wondering if this is the correct way to edit a method in another class too. Oh and this is my first script so expect the worst. :dead:
Thanks for any help.
This is the class its in, I'm also wondering if this is the correct way to edit a method in another class too. Oh and this is my first script so expect the worst. :dead:
Code:
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# Adds the ability to change event interaction when holding an item
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Front Event Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# Calculate front event coordinates
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
#--------------------------------------------------
# If you're holding an item
if $holding
comment = SDK.event_comment_input(event, 1, "Holding").to_s.split('|')
item_id = comment[0].to_i
switch_id = comment[1].to_i
# If the item you're holding and the item_id of the event comment match
if $holding == item_id
$game_switches[switch_id] = true
else
$game_system.se_play($data_system.cancel_se)
return false
end
else
event.start
end
#--------------------------------------------------
result = true
end
end
end
# If fitting event is not found
if result == false
# If front tile is a counter
if $game_map.counter?(new_x, new_y)
# Calculate 1 tile inside coordinates
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
end
Thanks for any help.