Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Attract Mode 1.10

Attract Mode
Version 1.10
By: Glitchfinder


Glitchfinder's Attract Mode is a script that allows you to mimic a classic feature of both arcade and console games. This script will modify the title screen so that, when left idle, it will take the game to a map. While on the map, the game will function normally, with the exception that any input from the player takes you back to the title screen. It is recommended that you set up an autorun or parallel process event on the map, to provide some sort of cinematic while the game is idle.

Features

  • Replicate a classic game feature!
  • Introduce the game before starting!
  • Entertain those who wait!

Screenshots

While this script is too dynamic to properly show through screenshots, I do have a video I can show:

http://www.youtube.com/watch?v=M0qiDKhjvvs

Scripts
Ruby:
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

# ** Team Scriptastic's Attract Mode                             [RPG Maker XP]

#    Version 1.10

#------------------------------------------------------------------------------

#  This script adds an "attract mode" feature.  If you let the game idle on the

#  title screen for a few seconds, it loads a predesignated map.  With some

#  decent eventing, you could have it play out whatever scene you like.

#  Pressing any button returns you to the title screen.

#==============================================================================

# * Version History

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#   Version 1.00 ------------------------------------------------- (2009-07-??)

#     - Initial Version

#     - Author: Glitchfinder

#    Version 1.10 ------------------------------------------------ (2009-07-??)

#      - Script modified for ease of use

#      - Author: theory

#==============================================================================

# * Instructions

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Place this script above Main, and below the default scripts. (I realize this

#  is obvious to most, but some people don't get it.)

#

#  There is a Scriptastic class immediately following this header. Just change

#  the settings found there to your liking.  This script is very simple to use.

#  Note that map is specified by ID.  This is the number displayed on the

#  status bar of RPG Maker XP while editing a map, to the left of the map name.

#  For example, 001: MAP001 (20x15)

#  1 would be the ID of this map, although 001 could technically be used.

#  This number can also be found in the title of the Map Properties window.

#==============================================================================

# * Contact

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Glitchfinder, the author of this script, may be contacted through his

#  website, found at [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#

#  You may also find Glitchfinder at [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#==============================================================================

# * Usage

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  This script may be used with the following terms and conditions:

#

#    1. This script is free to use in any noncommercial project. If you wish to

#       use this script in a commercial (paid) project, please contact

#       Glitchfinder at his website.

#    2. This script may only be hosted at the following domains:

#         [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#         [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#    3. If you wish to host this script elsewhere, please contact Glitchfinder.

#    4. If you wish to translate this script, please contact Glitchfinder. He

#       will need the web address that you plan to host the script at, as well

#       as the language this script is being translated to.

#    5. This header must remain intact at all times.

#    6. Glitchfinder remains the sole owner of this code. He may modify or

#       revoke this license at any time, for any reason.

#    7. Any code derived from code within this script is owned by Glitchfinder,

#       and you must have his permission to publish, host, or distribute his

#       code.

#    8. This license applies to all code derived from the code within this

#       script.

#    9. If you use this script within your project, you must include visible

#       credit to Glitchfinder and theory, within reason.

#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

 

class Scriptastic

  def initialize

    @attract_mode_map = 1  # Which map to start on

    @attract_start_x  = 9  # Which tile, horizontally, to start on

    @attract_start_y  = 7  # Which tile, vertically, to start on

    @attract_wait     = 10 # How many seconds to wait

  end

  attr_accessor :attract_mode_map

  attr_accessor :attract_start_x

  attr_accessor :attract_start_y

  attr_accessor :attract_wait

end

 

$scriptastic = Scriptastic.new if $scriptastic == nil

#==============================================================================

# ** Game_Map

#------------------------------------------------------------------------------

#  This class handles the map. It includes scrolling and passable determining

#  functions. Refer to "$game_map" for the instance of this class.

#==============================================================================

 

class Game_Map

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :attract_mode             # tileset file name

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_game_map_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    scriptastic_attract_mode_game_map_initialize

    @attract_mode = false

  end

end

 

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs title screen processing.

#==============================================================================

 

class Scene_Title

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_scene_title_main main

  alias scriptastic_attract_mode_scene_title_update update

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    @attract_wait = $scriptastic.attract_wait * Graphics.frame_rate

    scriptastic_attract_mode_scene_title_main

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    scriptastic_attract_mode_scene_title_update

    if @attract_wait <= 0

      begin_attract_mode

    else

      @attract_wait -= 1

    end

  end

  #--------------------------------------------------------------------------

  # * Command: Begin Attract Mode

  #--------------------------------------------------------------------------

  def begin_attract_mode

    # Make each type of game object

    $game_temp          = Game_Temp.new

    $game_system        = Game_System.new

    $game_switches      = Game_Switches.new

    $game_variables     = Game_Variables.new

    $game_self_switches = Game_SelfSwitches.new

    $game_screen        = Game_Screen.new

    $game_actors        = Game_Actors.new

    $game_party         = Game_Party.new

    $game_troop         = Game_Troop.new

    $game_map           = Game_Map.new

    $game_player        = Game_Player.new

    # Set up initial party

    $game_party.setup_starting_members

    # Set up initial map position

    $game_map.setup($scriptastic.attract_mode_map)

    # Set attract mode to on

    $game_map.attract_mode = true

    # Move player to initial position

    $game_player.moveto($scriptastic.attract_start_x,

                        $scriptastic.attract_start_y)

    # Refresh player

    $game_player.refresh

    # Run automatic change for BGM and BGS set with map

    $game_map.autoplay

    # Update map (run parallel process event)

    $game_map.update

    # Switch to map screen

    $scene = Scene_Map.new

  end

end

 

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  This class performs map screen processing.

#==============================================================================

 

class Scene_Map

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_scene_map_update update

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    if ((Input.trigger?(Input::A) || Input.trigger?(Input::B) ||

      Input.trigger?(Input::C) || Input.trigger?(Input::X) ||

      Input.trigger?(Input::Y) || Input.trigger?(Input::Z) ||

      Input.trigger?(Input::L) || Input.trigger?(Input::R) ||

      Input.trigger?(Input::DOWN) || Input.trigger?(Input::LEFT) ||

      Input.trigger?(Input::RIGHT) || Input.trigger?(Input::UP) ||

      Input.trigger?(Input::F5) || Input.trigger?(Input::F6) ||

      Input.trigger?(Input::F7) || Input.trigger?(Input::F8) ||

      Input.trigger?(Input::F9) || Input.trigger?(Input::SHIFT) ||

      Input.trigger?(Input::CTRL) || Input.trigger?(Input::ALT) ||

      Input.dir8 != 0) && $game_map.attract_mode == true)

      $game_player.straighten

      $game_map.attract_mode = false

      $scene = Scene_Title.new

    end

    scriptastic_attract_mode_scene_map_update

  end

end
Ruby:
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

# ** Team Scriptastic's Attract Mode                             [RPG Maker VX]

#    Version 1.10

#------------------------------------------------------------------------------

#  This script adds an "attract mode" feature.  If you let the game idle on the

#  title screen for a few seconds, it loads a predesignated map.  With some

#  decent eventing, you could have it play out whatever scene you like.

#  Pressing any button returns you to the title screen.

#==============================================================================

# * Version History

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#   Version 1.00 ------------------------------------------------- (2009-07-??)

#     - Initial Version

#     - Author: Glitchfinder

#    Version 1.10 ------------------------------------------------ (2009-07-??)

#      - Script modified for ease of use

#      - Author: theory

#==============================================================================

# * Instructions

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Place this script above Main, and below the default scripts. (I realize this

#  is obvious to most, but some people don't get it.)

#

#  There is a Scriptastic class immediately following this header. Just change

#  the settings found there to your liking.  This script is very simple to use.

#  Note that map is specified by ID.  This is the number displayed on the

#  status bar of RPG Maker XP while editing a map, to the left of the map name.

#  For example, 001:MAP001 (20x15)

#  1 would be the ID of this map, although 001 could technically be used.

#  This number can also be found in the title of the Map Properties window.

#==============================================================================

# * Contact

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Glitchfinder, the author of this script, may be contacted through his

#  website, found at [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#

#  You may also find Glitchfinder at [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#==============================================================================

# * Usage

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  This script may be used with the following terms and conditions:

#

#    1. This script is free to use in any noncommercial project. If you wish to

#       use this script in a commercial (paid) project, please contact

#       Glitchfinder at his website.

#    2. This script may only be hosted at the following domains:

#         [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#         [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#    3. If you wish to host this script elsewhere, please contact Glitchfinder.

#    4. If you wish to translate this script, please contact Glitchfinder. He

#       will need the web address that you plan to host the script at, as well

#       as the language this script is being translated to.

#    5. This header must remain intact at all times.

#    6. Glitchfinder remains the sole owner of this code. He may modify or

#       revoke this license at any time, for any reason.

#    7. Any code derived from code within this script is owned by Glitchfinder,

#       and you must have his permission to publish, host, or distribute his

#       code.

#    8. This license applies to all code derived from the code within this

#       script.

#    9. If you use this script within your project, you must include visible

#       credit to Glitchfinder and theory, within reason.

#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

 

class Scriptastic

  def initialize

    @attract_mode_map = 1  # Which map to start on

    @attract_start_x  = 10  # Which tile, horizontally, to start on

    @attract_start_y  = 6  # Which tile, vertically, to start on

    @attract_wait     = 10 # How many seconds to wait

  end

  attr_accessor :attract_mode_map

  attr_accessor :attract_start_x

  attr_accessor :attract_start_y

  attr_accessor :attract_wait

end

 

$scriptastic = Scriptastic.new if $scriptastic == nil

#==============================================================================

# ** Game_Map

#------------------------------------------------------------------------------

#  This class handles the map. It includes scrolling and passable determining

#  functions. Refer to "$game_map" for the instance of this class.

#==============================================================================

 

class Game_Map

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :attract_mode             # tileset file name

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_game_map_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    scriptastic_attract_mode_game_map_initialize

    @attract_mode = false

  end

end

 

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs title screen processing.

#==============================================================================

 

class Scene_Title

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_scene_title_main main

  alias scriptastic_attract_mode_scene_title_update update

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    @attract_wait = $scriptastic.attract_wait * Graphics.frame_rate

    scriptastic_attract_mode_scene_title_main

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    scriptastic_attract_mode_scene_title_update

    if @attract_wait <= 0

      begin_attract_mode

    else

      @attract_wait -= 1

    end

  end

  #--------------------------------------------------------------------------

  # * Command: Begin Attract Mode

  #--------------------------------------------------------------------------

  def begin_attract_mode

    # Make each type of game object

    $game_temp          = Game_Temp.new

    $game_system        = Game_System.new

    $game_switches      = Game_Switches.new

    $game_variables     = Game_Variables.new

    $game_self_switches = Game_SelfSwitches.new

    $game_screen        = Game_Screen.new

    $game_actors        = Game_Actors.new

    $game_party         = Game_Party.new

    $game_troop         = Game_Troop.new

    $game_map           = Game_Map.new

    $game_player        = Game_Player.new

    # Set up initial party

    $game_party.setup_starting_members

    # Set up initial map position

    $game_map.setup($scriptastic.attract_mode_map)

    # Set attract mode to on

    $game_map.attract_mode = true

    # Move player to initial position

    $game_player.moveto($scriptastic.attract_start_x,

                        $scriptastic.attract_start_y)

    # Refresh player

    $game_player.refresh

    # Run automatic change for BGM and BGS set with map

    $game_map.autoplay

    # Update map (run parallel process event)

    $game_map.update

    # Switch to map screen

    $scene = Scene_Map.new

  end

end

 

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  This class performs map screen processing.

#==============================================================================

 

class Scene_Map

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias scriptastic_attract_mode_scene_map_update update

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    if ((Input.trigger?(Input::A) || Input.trigger?(Input::B) ||

      Input.trigger?(Input::C) || Input.trigger?(Input::X) ||

      Input.trigger?(Input::Y) || Input.trigger?(Input::Z) ||

      Input.trigger?(Input::L) || Input.trigger?(Input::R) ||

      Input.trigger?(Input::DOWN) || Input.trigger?(Input::LEFT) ||

      Input.trigger?(Input::RIGHT) || Input.trigger?(Input::UP) ||

      Input.trigger?(Input::F5) || Input.trigger?(Input::F6) ||

      Input.trigger?(Input::F7) || Input.trigger?(Input::F8) ||

      Input.trigger?(Input::F9) || Input.trigger?(Input::SHIFT) ||

      Input.trigger?(Input::CTRL) || Input.trigger?(Input::ALT) ||

      Input.dir8 != 0) && $game_map.attract_mode == true)

      $game_player.straighten

      $game_map.attract_mode = false

      $scene = Scene_Title.new

    end

    scriptastic_attract_mode_scene_map_update

  end

end
Demo Links

The RMXP demo can be found here, while the RMVX demo can be found here.

Instructions

Place this script above Main, and below the default scripts. (I realize this is obvious to most, but some people don't get it.)

There is a Scriptastic class immediately following this header. Just change the settings found there to your liking. This script is very simple to use. Note that map is specified by ID. This is the number displayed on the status bar of RPG Maker XP while editing a map, to the left of the map name.
  • For example, 001: MAP001 (20x15)
1 would be the ID of this map, although 001 could technically be used. This number can also be found in the title of the Map Properties window.

Terms and Conditions

  • This script is free to use in any noncommercial project. If you wish to use this script in a commercial (paid) project, please contact Glitchfinder at his website.
  • This script may only be hosted at the following domains:
  • If you wish to host this script elsewhere, please contact Glitchfinder.
  • If you wish to translate this script, please contact Glitchfinder. He will need the web address that you plan to host the script at, as well as the language this script is being translated to.
  • The script header must remain intact at all times.
  • Glitchfinder remains the sole owner of this code. He may modify or revoke this license at any time, for any reason.
  • Any code derived from code within this script is owned by Glitchfinder, and you must have his permission to publish, host, or distribute his code.
  • This license applies to all code derived from the code within this script.
  • If you use this script within your project, you must include visible credit to Glitchfinder and theory, within reason.
 

boon

Sponsor

lol jk xD

nah, I'm really impressed with this. I take it that I could always set up a scripted event or a scripted series of events so that say, i can have a full preview of the game play?
 
As you're running an instance of Game_Map, yes, you can do everything you can in a regular map. With the instance og Game_Player missing, though, I suppose the only way you can scroll the map is by using the Scroll Map event command (however I might be wrong there totally... didn't look at the script ^^" ). You definately won't be able to move a character though.

@Glitch: From the change notes, I figure theory was the one really doing this 1.1 update, no? ^^ Either way, I figure what actually got changed, as I never really looked at the old version (with the exception of the video that didn't change...)
As for suggestions, I can only think of including the possibility to define attract maps in an array instead of only having a single one.

As always, keep up the good work.
 

regi

Sponsor

Very nice concept! I remember a few people looking for this back in the day; it's a nice alternative for those too lazy to use evented title screens :3

This is probably nothing big, but would it save any processing time at all if you put "if $game_map.attract_mode == true" before the rest of the Input.trigger checks? And is there anyway to clean up that section (like a mass-button check feature in RGSS? no?)
 
boon":2dlxqg6e said:
lol jk xD

nah, I'm really impressed with this. I take it that I could always set up a scripted event or a scripted series of events so that say, i can have a full preview of the game play?
Actually, with this, you can do anything you can do in a regular game, with the exception of pressing buttons, which would take you back to the title screen.

BlueScope":2dlxqg6e said:
As you're running an instance of Game_Map, yes, you can do everything you can in a regular map. With the instance og Game_Player missing, though, I suppose the only way you can scroll the map is by using the Scroll Map event command (however I might be wrong there totally... didn't look at the script ^^" ). You definately won't be able to move a character though.

@Glitch: From the change notes, I figure theory was the one really doing this 1.1 update, no? ^^ Either way, I figure what actually got changed, as I never really looked at the old version (with the exception of the video that didn't change...)
As for suggestions, I can only think of including the possibility to define attract maps in an array instead of only having a single one.

As always, keep up the good work.
Actually, this initializes everything that gets initialized on a new game, which means that there is an instance of Game_Player. In fact, the only difference is that a flag is set to true, that causes it to check for input and go back to the title if it is found.

And yes, the most recent update is entirely by theory. However, I posted it here because I realized that I had actually never posted the script to hbgames, and instead had merely linked to it in one post, and put a second link in my signature.

And before you mention it, the Scriptastic class is by theory. It's a very poor design element, and if I update this script, that goes into an initialize method somewhere instead.

As for the possibility to define them in an array, do you mean so that it goes to a random map in the array, instead of simply going to the same map, over and over? I could do a map rotation too... Hmm. This bears thinking over.

Regicida":2dlxqg6e said:
Very nice concept! I remember a few people looking for this back in the day; it's a nice alternative for those too lazy to use evented title screens :3

This is probably nothing big, but would it save any processing time at all if you put "if $game_map.attract_mode == true" before the rest of the Input.trigger checks? And is there anyway to clean up that section (like a mass-button check feature in RGSS? no?)
Actually, if I insisted on using &&, it wouldn't make a difference. However, something I've learned since making this script is that if I moved that to the front and change the && to and, it would actually check that first, and move on to the rest of the method if it didn't evaluate to true.

As for the actual input checking, there isn't really a better way to do it. The input class does not have a method to check for any key being pressed, and, as such, I have to do it this one. One thing to note is that, in the next release of my keyboard module, I will have the new key constant "ANYKEY", which would cause a method to return true if any of the other keys would make it return true. (Just a simple "if array.include?(true)" check, and it's in)
 

regi

Sponsor

Glitchfinder":1hi61lkr said:
However, something I've learned since making this script is that if I moved that to the front and change the && to and, it would actually check that first, and move on to the rest of the method if it didn't evaluate to true.
Yup, that's what I meant, cutting down the unnecessary Input checks if attract mode was off. Of course, it probably couldn't make too much difference.
 

Zeriab

Sponsor

I just want to note that you can in events tell what the next map and starting position will be.
Code:
$scriptastic.attract_mode_map = 2

$scriptastic.attract_start_x = 10

$scriptastic.attract_start_y = 12

Note also that you can freely use switches and variables as they will not be remembered after the scenes ends or the player breaks the command.
You should be careful doing anything that changes the current scene such as opening the menu and going into a battle.
 
Glitch, you still didn't use the code I told you about.

[rgss] 
 
for i in 0...255
  if Input.trigger?(i)
    # do stuff
  end
end
 
 
[/rgss]

I dunno if that's the best way, but in my opinion, it's much better than having all those separate checks.
 
Ulqiorra":12rptjqb said:
Glitch, you still didn't use the code I told you about.

[rgss] 
 
for i in 0...255
  if Input.trigger?(i)
    # do stuff
  end
end
 
 
[/rgss]

I dunno if that's the best way, but in my opinion, it's much better than having all those separate checks.

While that would work with my input script (assuming you changed it to Keys.trigger?) it won't really do what it needs to in the default one. (Although, the keys in that default module MAY be given numbers that could allow me to hit them all w/o going through 255.) In any event, they do not coincide to their read key IDs.

Plus, if you noticed, this version is from long before you made that suggestion.
 

Zeriab

Sponsor

Speed wise you should put $game_map.attract_mode == true as the first argument of the conjunction.
Doing an iterated solution of the triggers is most likely slower, but it is easier to manage.

Being lazy myself I would just have done something like this:
[rgss]  Triggers = [Input::A, Input::B, Input::C]
  def self.action_trigger?
    result = Triggers.find {|trigger| Input.trigger?(trigger)}
    return result.nil? ? false : true
  end
[/rgss]

Proof of concept only since I am too lazy to do more.

*hugs*
 
I only comment this just in case a newbie reads some of the previous post and ignores these facts about Ruby.
___________

Remember there's no need to use...

if $game_map.attract_mode == true

...because it'll always evaluate to true if it exists (this is so almost all the time) or it's equal to true (just in case it's a kind of switch like in this case).

if $game_map.attract_mode

...is more than enough to perform the check just like its negated version would

if !$game_map.attract_mode

unless $game_map.attract_mode
 
Since you're on the subject of basic ruby, you might want to mention the fact that, if you're unsure a variable is defined, you should check that it's defined before you check it for a value, like so:

Ruby:
if defined(variable)

  if variable

    # some stuff here

  end

end

This helps to prevent the oft encountered and much lamented nilClass error.

As a note to anybody else planning to comment on my code, this script has been left untouched for over a year. (Check the version history, and pay close attention to the year. It's in the format yyyy-mm-dd) My coding style has changed (and improved) drastically over that period of time, which means that you're beating a long dead horse.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top