Started by G_G, June 06, 2011, 02:19:50 am
#===============================================================================# More Self-Switches# Version 1.5# Author game_guy#-------------------------------------------------------------------------------# Intro:# Ever need more than 4 self switches? With this small script, you can now# have as many self switches you want. You aren't just limited to letters# either. You can have names for them.## Features:# -More Self Switches# -Name them whatever# -Access/toggle them at anytime## Instructions:# -First, lets create a self switch for our event. Anywhere in the event, add# a comment and type this,# Switch:switch_name.# switch_name can be whatever you want to name the switch. Thats all you have# to do to create a self switch for that page.# There cannot be any spaces between the colon and the switch name.# e.g. Switch: switch - Does not work.# e.g. Switch:switch - Does work.## -Now to turn this switch of or on, call this in a script call.# self_switch("switch", true/false)# switch is the switch name, this must be in double " " or single ' ' quotes.# true/false tells the script whether to turn it off or on. true = on, # false = off.## -If you want to see if a self switch is on/off, use this script in a# condtional branch.# self_switch_state("switch") == true/false# switch is the switch name, this must be in double " " or single ' ' quotes.# true = on, false = off## -Now you can toggle switches/check switch state of any event.# Just use these script calls:# self_switch("switch", true/false, event_id)# self_switch_state("switch", event_id)# The previous script calls still work without event_id, it just works within the event then.## Compatibility:# Not tested with SDK.# Should work with anything.## Credits:# game_guy ~ For creating it.# Thanks to KK20 for a Bug Fix#===============================================================================$gg_self_switches = 1.5class Game_Event < Game_Character alias gg_init_more_switches_lat initialize def initialize(map_id, event) gg_init_more_switches_lat(map_id, event) @event.pages.each {|page| page.list.each {|command| if [108, 408].include?(command.code) command.parameters.each {|p| check_custom_switch(page, p) } end }} refresh end def check_custom_switch(page, code) a = code.split(':') return if a[0].nil? if a[0].downcase == "switch" && a[1] != nil page.condition.self_switch_ch = a[1] page.condition.self_switch_valid = true end endendclass Interpreter def self_switch(switch, state, event_id = @event_id) key = [$game_map.map_id, event_id, switch] $game_self_switches[key] = state $game_map.need_refresh = true end def self_switch_state(switch, event_id = @event_id) key = [$game_map.map_id, event_id, switch] return $game_self_switches[key] endend
$game_self_switches[[$game_map.map_id, @event_id, 'STRING']] = true
Switch:custom_switch
self_switch("custom_switch", true)
QuoteScript 'More Self Switches' line 59: NoMethodError occurred. undefined Method 'downcase' for nil:NilClass
This is my comment.I just made a line break.
class Game_Event < Game_Character alias gg_init_more_switches_lat initialize def initialize(map_id, event) gg_init_more_switches_lat(map_id, event) @event.pages.each {|page| page.list.each {|command| if [108, 408].include?(command.code) command.parameters.each {|p| check_custom_switch(page, p) } end }} refresh end def check_custom_switch(page, code) a = code.split(':') return if a[0].nil? if a[0].downcase == "switch" && a[1] != nil page.condition.self_switch_ch = a[1] page.condition.self_switch_valid = true end endendclass Interpreter def self_switch(switch, state) if @event_id > 0 key = [$game_map.map_id, @event_id, switch] $game_self_switches[key] = state end $game_map.need_refresh = true end def self_switch_state(switch) key = [$game_map.map_id, @event_id, switch] return $game_self_switches[key] endend
Quoteclass Interpreter def self_switch(switch, state) self_switch(switch, state, @event_id) if @event_id > 0 end def self_switch(switch, state, event_id) key = [$game_map.map_id, event_id, switch] $game_self_switches[key] = state $game_map.need_refresh = true end def self_switch_state(switch) return self_switch_state(switch, @event_id) end def self_switch_state(switch, event_id) key = [$game_map.map_id, event_id, switch] return $game_self_switches[key] endend
Quoteclass Interpreter def self_switch(switch, state, event_id = @event_id) key = [$game_map.map_id, event_id, switch] $game_self_switches[key] = state $game_map.need_refresh = true end def self_switch_state(switch, event_id = @event_id) key = [$game_map.map_id, event_id, switch] return $game_self_switches[key] endend
Quote from: gameus on September 21, 2013, 08:13:09 pm...been working with C#, and before .NET 4.0, you can't have default arguments...
Quote from: ForeverZer0 on September 23, 2013, 07:18:34 amQuote from: gameus on September 21, 2013, 08:13:09 pm...been working with C#, and before .NET 4.0, you can't have default arguments...Not true, works in .NET 2.0. I haven't used any version lower than that, but it's been around for a while.
Quote from: winkioI do not speak to bricks, either as individuals or in wall form.
Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.