Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Reseting self-switch on map enter/leave, Sort of like how Erase Event works
Titanhex
post Sep 14 2011, 10:28 PM
Post #1


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Alright so we all know how Erase Event works. The event is erased, then when you re-enter the map the Event comes back until you erase it again.

I want to do something similar but with self switches.

On entering the map, all the events run an autorun that sets up the technical details and it's graphic. It then turns on a self switch, which makes it interactive by touching it.

Now, if the player leaves the map, or saves in the map, when he returns all the events don't have graphics because they didn't run the autorun.

My solution was to run a self-switch reseter on autorun in the top left like this:

for i in 1..30
$game_self_switches[[$game_map.map_id, i, "B"]]=false
end
$game_map.need_refresh = true

But I would rather just leave it up to the event instead of do it in a batch which may reset other event's self-switches accidentally.

Is there an easy, simple way to make a self switch reset on map enter/leave, preferably without making a new event?


__________________________
Go to the top of the page
 
+Quote Post
   
Pharonix
post Sep 16 2011, 08:22 AM
Post #2


Eventer. Gamer. Writer.
Group Icon

Group: Revolutionary
Posts: 155
Type: Event Designer
RM Skill: Intermediate
Rev Points: 25




There's never an easy way to do anything cool

when you start the leave map transition set a new switch to on, then make an event page in each event that you want the self switch to turn off on - this one will have the switch you set in the transition as a pre-requisite.
then turn the self switch off in the new event page.
then before the map transfer turn the new switch off.

This is just a quick guess though so it may not work.
but from what I've seen in the project I'm working on, It may be possible.

I have class in 15minutes so I can check after class if you want

This post has been edited by Pharonix: Sep 16 2011, 08:24 AM


__________________________

CURRENT WORKS
DEMON BLADE - RPGVXA
SHINIGAMI - ~12 Pages - 3 chapters complete, 1 in progress.
---------------------------------
OTHER WORKS
INCANTA-corrupted.
INCANTA REDUX - RPGVX - On Hold
---------------------------------
LITERARY WORKS

Longer Works
ANGEL OF DEATH - Short Story ~ 4 Pages.
SHINIGAMI - ~12 Pages - 3 chapters complete, 1 in progress.
DEMON BLADE - Book/Novel?- 34 pages - On Hold.
FERAL - Short Story, Length: 6 pages], 2nd person Narrative. -R3 Writing Competition #2 - First-Place
DARKSPAWN - Book - 3 Pages On Hold
RELGEA CHRONICLE - Book - 118 pages
DRAKENGHOUL - book - 36 handwritten pages

Poems
I KNOW - Poem - 30 Lines

Song Lyrics
End of Days - Song- 44 Lines
Kids Killing Kids - Song - 94 Lines




-If you want this sig in another language, move to a country that speaks it.-

-Lv 13 Thread Killer




My R3 Writing Corner



My Wordpress


Relgea Chronicle

X-M-O Story Quoting.
QUOTE (X-M-O @ Jun 19 2012, 02:45 AM) *
QUOTE (Pharonix)
so what's going on in this thread?

QUOTE (kayden997)
Redd's back and the first thing he does is...

QUOTE (Pharonix)
pick my mom up in 15
...*sigh*

QUOTE (kayden997)
You know it's legit!

QUOTE (Pharonix)
Then again, I wrecked the last one...........

QUOTE (Tsutanai)
Oh ok you can have a pink frosted sprinkled doughnut

QUOTE (Pharonix)
I hate not having a car......
I miss my Alero...

QUOTE (Tsutanai)
you suck >:(


Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 16 2011, 11:40 AM
Post #3


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Not sure what you're looking for exactly, but try this:

spoiler

CODE
#==============================================================================
# * Night5h4d3's Self Switch Resetter
#------------------------------------------------------------------------------
# 9/16/2011  for: Titanhex
#------------------------------------------------------------------------------
# Descr:
#   Ressets self switches on the current map based on the events name
# How to use:
#   Add [N] to your event name, where N is the self switches (sepparated by
#   comma) to turn off (eg. [A, B, D])
# Config:
#   AUTO_RS_SS - This is the switch number to toggle automatic resseting of
#   self switches. turn the specified switch on to disable auto resetting.
# NOTE:
#   You can still reset self switches by using $scene.reset_sswitches(true),
#   this will force a reset of the specified self switches on the current map.
#------------------------------------------------------------------------------
# ** N5 module
#==============================================================================
module N5
  AUTO_RS_SS = 1
end
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a superclass of all scenes in the game.
#==============================================================================
class Scene_Base
  def reset_sswitches(force? = false)
    return if $game_switches[N5::AUTO_RS_SS] or force?
    @from_save    = from_save
    @name_slice   = []
    @temp_game_ss = $game_self_switches.clone
    for i in 1..$game_map.map.events.size
      if $game_map.map.events[i].name.include?("[")
        @name_slice[i] = $game_map.map.events[i].name.slice(/(\[)(.*)(\])/)
        @name_slice[i].gsub!(/[\[\,\]\s]/) {||}  
      end
    end
    for i in 0...@name_slice.size
      for n in 0...@name_slice[i].size
        if @name_slice[i] != nil
          $game_self_switches[[$game_map.map_id,
                               @name_slice[i],  
                               @name_slice[i][n]]] = false              
        end
      end
    end
    return @temp_game_ss
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Player Transfer  Processing
  #--------------------------------------------------------------------------
  def update_transfer_player
    return unless $game_player.transfer?
    fade = (Graphics.brightness > 0)
    fadeout(30) if fade
    @spriteset.dispose              # Dispose of sprite set
    reset_sswitches                 # N5 reset self switches
    $game_player.perform_transfer   # Execute player transfer
    $game_map.autoplay              # Automatically switch BGM and BGS
    $game_map.update
    Graphics.wait(15)
    @spriteset = Spriteset_Map.new  # Recreate sprite set
    fadein(30) if fade
    Input.update
  end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    @temp = reset_sswitches         # N5 reset self switches
    characters = []
    for actor in $game_party.members
      characters.push([actor.character_name, actor.character_index])
    end
    $game_system.save_count += 1
    $game_system.version_id = $data_system.version_id
    @last_bgm = RPG::BGM::last
    @last_bgs = RPG::BGS::last
    Marshal.dump(characters,           file)
    Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(@last_bgm,            file)
    Marshal.dump(@last_bgs,            file)
    Marshal.dump($game_system,         file)
    Marshal.dump($game_message,        file)
    Marshal.dump($game_switches,       file)
    Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches,  file)
    Marshal.dump($game_actors,         file)
    Marshal.dump($game_party,          file)
    Marshal.dump($game_troop,          file)
    Marshal.dump($game_map,            file)
    Marshal.dump($game_player,         file)
    $game_self_switches = @temp
  end
end


NOTE: This is in theory, I haven't tested it actually resetting the self switches. (can't yet)


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Titanhex
post Sep 17 2011, 02:23 AM
Post #4


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




@Pharonix: Sorry, but that's not too far removed from just resetting all self-switches in a batch on map entrance.

@Nightshade:I haven't tested it yet, but thanks for concocting this.

I'm wary of using it though, as it rewrites Scene_File's methods, which would conflict greatly with a lot of systems I use.

I'm curious, why can't you just alias these systems like I've done with this?

MG_Sys
CODE
class Scene_File
  
  alias oldWriteSaveMGSys write_save_data
  def write_save_data(file)
    oldWriteSaveMGSys(file)
    Marshal.dump($mgval,             file)
    Marshal.dump($mgtype,            file)
    Marshal.dump($mgquit,            file)
    Marshal.dump($mganim,            file)
  end

  alias oldReadSaveMGSys read_save_data
  def read_save_data(file)
    oldReadSaveMGSys(file)
    $mgval            = Marshal.load(file)
    $mgtype           = Marshal.load(file)
    $mgquit           = Marshal.load(file)
    $mganim           = Marshal.load(file)
  end

end


I'm still learning. So bare with me. If you think it'll be fine I can try to alias them myself.

What I'm looking for you seem to have guessed correctly. From what I can tell from the code it does what I want it to do.


__________________________
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 17 2011, 04:31 AM
Post #5


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




The map resetter can't be aliased, simply because the reset command needs to be run in the middle of the def, but as for scene_file the same is not true, I actually missed that and forgot that I could alias it, youd do it like so:
CODE
class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  alias n5_wsd_old(file) write_save_data(file
  def write_save_data(file)
    @temp = reset_sswitches         # N5 reset self switches
    n5_wsd_old(file)
    $game_self_switches = @temp # restore self switches
  end
end


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Titanhex
post Sep 21 2011, 08:04 AM
Post #6


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




It's giving me a Syntax error on Line 29 of the script. I changed force? to force.

Also this line: alias n5_wsd_old(file) write_save_data(file

doesn't need (file)

The only error left is a NameError.

Line 31: from_save isn't a local variable or method for Scene_Map

This post has been edited by Titanhex: Sep 21 2011, 08:14 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Helios
post Sep 26 2011, 02:23 AM
Post #7


Level 4
Group Icon

Group: Member
Posts: 54
Type: None
RM Skill: Undisclosed




Errr... never mind. I figured it out.

This post has been edited by Helios: Oct 7 2011, 06:59 PM


__________________________
ERROR: NO ERROR DETECTED
Go to the top of the page
 
+Quote Post
   
Titanhex
post Jan 6 2012, 10:52 PM
Post #8


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




LMAO, I still need help with that from_save error.

Also, this line gives errors:


for i in 0...@name_slice.size
for n in 0...@name_slice[i].size

with size.

I removed the [i] on it.

Sadly even after making these modifications (I commented out the line that had from_save) the script doesn't do what it should.

This post has been edited by Titanhex: Jan 8 2012, 12:16 AM


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 17th May 2013 - 09:52 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker