RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VXA] More Self-Switches

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 84
Yes, hoh my gawd!
More Self-Switches (VX Ace Edition)
Authors: game_guy
Version: 1.0
Type: Event Modification
Key Term: Environment Add-on

Introduction

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.

Ha! Literally changed 1 line to make it work!

Features

  • More Self Switches
  • Name them whatever

Screenshots

You do not need to check the self-switch box anymore!
Spoiler for:

Demo

No demo. Check the VX or XP version out for a demo.

Script

Spoiler for:
Code: [Select]
#===============================================================================
# More Self-Switches (VX Ace Edition)
# Version 1.0
# 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
#
# 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
#
# Compatibility:
# Should work with anything.
#
# Credits:
# game_guy ~ For creating it.
#===============================================================================

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(':')
    if !a[0].nil? && a[0].downcase == "switch" && a[1] != nil
      page.condition.self_switch_ch = a[1] 
      page.condition.self_switch_valid = true
    end
  end
end

class Game_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]
  end
end

VX Version Here

Instructions

In the script.
Place above main, below Scene_Debug, the normal.

Compatibility

Should work with anything.

Credits and Thanks

  • game_guy ~ For creating it.

Author's Notes

Enjoy! :)
« Last Edit: March 03, 2012, 10:41:26 PM by game_guy »

pokeball ze1Offline
**
Rep: +0/-0Level 72
RMRK Junior
The game crashes if an event has an empty comment.

To avoid that, I edited the check_custom_switch method

Code: [Select]
def check_custom_switch(page, code)
    a = code.split(':')
    if !a[0].nil? && a[0].downcase == "switch" && a[1] != nil # Edited this line
      page.condition.self_switch_ch = a[1] 
      page.condition.self_switch_valid = true
    end
  end

***
Rep:
Level 84
Yes, hoh my gawd!
Thanks, added in the fix, though I'm gonna be honest, I don't see why you'd leave an empty comment in an event. But oh well. Thanks. :3

pokeball ze1Offline
**
Rep: +0/-0Level 72
RMRK Junior
It wasn't on purpose. I left there on accident after editing an event many times. I just figured I should fix it to make the code more robust. =)