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.
[VX] More Self-Switches

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 84
Yes, hoh my gawd!
More Self-Switches
Authors: game_guy
Version: 1.1
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.

Features

  • More Self Switches
  • Name them whatever

Screenshots

This is a screenshot from the XP version, however, it works the exact same way.
Spoiler for:

Demo

http://www.mediafire.com/?xwfvy7k3zxb83ng (provided by Mitsarugi)
This demo is bugged but its still a great example on how to use this. :)

Script

Spoiler for:
Code: [Select]
#===============================================================================
# More Self-Switches
# Version 1.1
# 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.
# You also need the Self-Switch box on the page checked.
#
# -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:
# Not tested with SDK.
# 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].downcase == "switch" && a[1] != nil
      page.condition.self_switch_ch = a[1] 
    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
 

XP Version Here

Instructions

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

Compatibility

Not tested with SDK.
Should work with anything.

Credits and Thanks

  • game_guy ~ For creating it.

Author's Notes

Enjoy! :)
« Last Edit: July 29, 2011, 08:47:24 AM by game_guy »

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Very nice. A handy tip for sad souls who need more event conditions. I even bothered to look through your code, it looked all compatible there.
Good stuff g_g.
it's like a metaphor or something i don't know

***
Rep:
Level 81
Monster Hunter
Hi Game_Guy i really like your script so i made a demo for it ^^ hope it helps.
Here: http://www.mediafire.com/?xwfvy7k3zxb83ng
your script is a great help

***
Rep:
Level 84
Yes, hoh my gawd!
Hey thanks. :D *adds to post*

***
Rep:
Level 81
Monster Hunter
No problem my friend you help us (a lot) and we help you (how ever we can )^^

**
Rep: +0/-0Level 81
Rpg Maker VX Master
First of all, this is a cool and really useful script,
but I found a BIG bug.
All the self switches work fine, but when you make a map transfer and than return into the previous map, all the switches made are automatically reset !
an example:
I create an event, I set a red treasure chest as graphic, priority same as character, trigger action button.
In the Event Commands part i write using Script Call       
self_switch("BLUE", true)
Now I make another event page
I set as graphic a blue chest and I check the Self Switch Box
In the Event Command part I write using Comment   
Switch:BLUE
Now, in playtest, if I interact with the chest it becomes blue.
But if I go to another map and I return back, automatically the chest returns red, so the self switch BLUE I created turned off.
That's the problem. With this, I can't actually use your script !
Can you fix it ?
I really need your script, so please fix this bug and/or help me !
Visit my official website for resources, games, and informations.
Download for free my (great) videogames and resources.
Link:
http://thefrontera.knossus.net

Watch also my great videos !
Link: Awesome videos here

The VX Project I'm working on: (Click to see the Description)


ALL MY AWESOME COMPLETED GAMES [OPEN THE SPOILER!!!]
Spoiler for:
My Completed VX Games:
The Frontera Legends (Click to Download)


My Completed XP Games:
The Frontera 2 (Click to Download)


The Frontera 1
Unfortunatly I can't have more than three pictures in my signature...
However, download it HERE (without the cool image)

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
To fix that, g_g, I think you'd have to store the data in either Map, Temp or System. Probably Map, it'd be a bit odd in System (although you do need to have it remembered for save files!), but that's just me as a sounding board.
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 81
Rpg Maker VX Master
and... how can I do it ?
Visit my official website for resources, games, and informations.
Download for free my (great) videogames and resources.
Link:
http://thefrontera.knossus.net

Watch also my great videos !
Link: Awesome videos here

The VX Project I'm working on: (Click to see the Description)


ALL MY AWESOME COMPLETED GAMES [OPEN THE SPOILER!!!]
Spoiler for:
My Completed VX Games:
The Frontera Legends (Click to Download)


My Completed XP Games:
The Frontera 2 (Click to Download)


The Frontera 1
Unfortunatly I can't have more than three pictures in my signature...
However, download it HERE (without the cool image)

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I wasn't aiming that at you, rather game_guy.
it's like a metaphor or something i don't know

***
Rep:
Level 84
Yes, hoh my gawd!
Easy fix. Will do that now. And all data is already stored in $game_self_switches. It was just a matter of my fault for not accessing the data if it existed. I know more about RGSS/RGSS2 then you guys think. ;3

Actually, looking through my code, there should be no reason its doing that. O_o I'll go try and attempt to recreate this bug.

Fixed. Theres most likely a bug in RMXP now too. >_>
« Last Edit: July 29, 2011, 08:46:45 AM by game_guy »

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Oh, I know how skilled you are at RGSS. Not insulting your ability at all.
I also know that you're creating ARC and that's going to be an incredible thing on a resume on day.
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 81
Rpg Maker VX Master
Thanks game_guy, now it works ! 
Visit my official website for resources, games, and informations.
Download for free my (great) videogames and resources.
Link:
http://thefrontera.knossus.net

Watch also my great videos !
Link: Awesome videos here

The VX Project I'm working on: (Click to see the Description)


ALL MY AWESOME COMPLETED GAMES [OPEN THE SPOILER!!!]
Spoiler for:
My Completed VX Games:
The Frontera Legends (Click to Download)


My Completed XP Games:
The Frontera 2 (Click to Download)


The Frontera 1
Unfortunatly I can't have more than three pictures in my signature...
However, download it HERE (without the cool image)

*
Rep: +0/-0Level 34
RMRK Junior
I am not able to see it work.

Could someone explain me better?
A print screen?