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.

A "There's nothing unusual here"-script

[If there's something at the topic that doesn't obey the rules, please feel free to move or delete it. Inform me via PM if so. Thanks.]

RMXP or RMVX:
RPG Maker VX

Detailed Description:
I'd like to have a script that checks whether there's an event or something to interact with, using the action button. If there's nothing, a common event will be executed.
In other words, I'd like the script to be able to let my main character say something like "There's nothing unusual here.", in case there's nothing to interact with in front or below the player.

Other Scripts I am using:
Other than all those standard scripts that came along with RMVX, I use no spectacular ones.
 
Not to be rude, but why? I can't see any advantage to that except annoying the player with a message that they don't need to read. Although, if you want it like the Earthbound/Mother series, just make an invisible event and put it on every wall/ object in every map which can be done simply by copying and pasting the same event over and over.

I advise you don't do it to floor tiles though because NPCs won't be able to walk through them (I believe) and it'd be annoying to see that window pop up every time the player accidentally presses the Z/Enter/whatever key when they wanted to press the cancel button to open the main menu.
 
Gelatos":3ut2obkx said:
Not to be rude, but why? I can't see any advantage to that except annoying the player with a message that they don't need to read. Although, if you want it like the Earthbound/Mother series, just make an invisible event and put it on every wall/ object in every map which can be done simply by copying and pasting the same event over and over.

I advise you don't do it to floor tiles though because NPCs won't be able to walk through them (I believe) and it'd be annoying to see that window pop up every time the player accidentally presses the Z/Enter/whatever key when they wanted to press the cancel button to open the main menu.

Actually, your method is bound to create lag. Anyway, it's fairly simple to execute with a script, and could actually be more advanced. (For example, instead of simply saying "There's nothing unusual here", it would check to see what kind of tile the player is facing, and execute a message based on what it is.)

Oh well, here we go. I've made a script that will execute a message for every non-ground/wall tile. (As in, impassable tiles that take up space as furniture, on furniture, or simply on the ground) THere are two messages. The first is if the tile looks like it could hold something, in which case the message is "There is nothing unusual inside". Otherwise, it prints the message "There is nothing unusual here." Here's the script:

Code:
#==============================================================================

# ** Vocab

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

#  This module defines terms and messages. It defines some data as constant

# variables. Terms in the database are obtained from $data_system.

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

 

module Vocab

  # Nothing Unusual

  Unusual = "There's nothing unusual "

  Inside  = 'inside.'

  Here    = 'here.'

end

 

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

# ** Unusual

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

#  This module defines checkable tiles and their output. The instance of this

# class is referenced by $game_player.

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

 

module Unusual

  Inside = [72, 75, 77, 97, 128, 131, 133, 145, 314, 315, 316, 317, 318, 319,

            328, 329, 330, 331, 332, 333, 334, 335, 393, 395, 396, 397, 448,

            449, 456, 457, 464, 465, 472, 473, 480, 481, 484, 485, 488, 489,

            490, 491, 494, 495, 496, 497, 498, 499, 504, 505, 506, 507, 526,

            527, 637, 638, 639, 682, 683, 684, 670, 671, 678, 679]

  Here   = [78, 79, 84, 86, 87, 92, 93, 94, 95, 96, 98, 105, 109, 110, 111,

            112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123, 125, 126,

            127, 134, 135, 140, 142, 143, 144, 146, 148, 149, 150, 151, 336,

            337, 338, 339, 340, 342, 343, 344, 345, 346, 347, 348, 350, 351,

            352, 353, 354, 355, 356, 357, 358, 359, 363, 364, 365, 366, 367,

            368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380,

            381, 382, 383, 432, 433, 434, 435, 436, 437, 438, 439, 442, 444,

            445, 447, 450, 451, 452, 453, 454, 455, 458, 459, 460, 461, 462,

            463, 466, 467, 468, 469, 470, 471, 474, 475, 476, 477, 478, 479,

            486, 487, 502, 510, 511, 516, 517, 518, 524, 525, 536, 537, 538,

            539, 540, 541, 542, 543, 552, 553, 554, 555, 556, 557, 558, 559,

            568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580,

            581, 582, 583, 584, 585, 586, 587, 588, 589, 641, 648, 649, 650,

            651, 652, 653, 654, 655, 662, 663, 664, 665, 666, 667, 668, 669,

            675, 676, 677, 680, 681, 688, 689, 690, 691, 692, 696, 697, 698,

            699, 700, 701, 712, 713, 714, 715, 716, 717, 718, 719, 726, 727,

            734, 735, 742, 743, 748, 749, 750, 751]

end

  

 

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

# ** Game_Player

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

#  This class handles maps. It includes event starting determinants and map

# scrolling functions. The instance of this class is referenced by $game_map.

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

 

class Game_Player < Game_Character

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

  # * Alias Methods

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

  alias glitch_unusual_update_nonmoving update_nonmoving

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

  # * Processing when not moving

  #     last_moving : Was it moving previously?

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

  def update_nonmoving(last_moving)

    if not $game_message.visible and Input.trigger?(Input::C)

      check_tile

    end

    glitch_unusual_update_nonmoving(last_moving)

  end

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

  # * Check Tile

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

  def check_tile

    if @direction == 2

      tile_data = $game_map.data[@x, @y + 1, 2]

    elsif @direction == 4

      tile_data = $game_map.data[@x - 1, @y, 2]

    elsif @direction == 6

      tile_data = $game_map.data[@x + 1, @y, 2]

    elsif @direction == 8

      tile_data = $game_map.data[@x, @y - 1, 2]

    end

    return if tile_data == nil || tile_data == 0

    if Unusual::Inside.include?(tile_data)

      text = Vocab::Unusual + Vocab::Inside

      $game_message.texts.push(text)

    elsif Unusual::Here.include?(tile_data)

      text = Vocab::Unusual + Vocab::Here

      $game_message.texts.push(text)

    end

  end

end

Now, it should be plug 'n play, so tell me if there's a problem. Also, I purposely omitted the four sign tiles from being included in the message producing tiles, simply because they are intended to have events over them.
 
Thanks. But the thing is: I don't want this to be said just like that. I would like to let my main character say that, so there has to be the possiblity to set a face and make the text multiple lines long. What would have to be changed?

Alternatively, a common event could be executed for each of the different circumstances.
 
mk1995":34zqw0ng said:
Thanks. But the thing is: I don't want this to be said just like that. I would like to let my main character say that, so there has to be the possiblity to set a face and make the text multiple lines long. What would have to be changed?

Alternatively, a common event could be executed for each of the different circumstances.

Give me a minute and I'll edit this post with a new version where the main character will say it instead. I'm not sure how to make it multiple lines, but I'll check into it.

Edit: OK, I figured them both out. First off, here's the script where the main character will say it. TO change what he says, you've got to edit the vocab at the top.

Code:
#==============================================================================

# ** Vocab

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

#  This module defines terms and messages. It defines some data as constant

# variables. Terms in the database are obtained from $data_system.

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

 

module Vocab

  # Nothing Unusual

  Unusual = "There's nothing unusual "

  Inside  = 'inside.'

  Here    = 'here.'

end

 

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

# ** Unusual

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

#  This module defines checkable tiles and their output. The instance of this

# class is referenced by $game_player.

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

 

module Unusual

  Inside = [72, 75, 77, 97, 128, 131, 133, 145, 314, 315, 316, 317, 318, 319,

            328, 329, 330, 331, 332, 333, 334, 335, 393, 395, 396, 397, 448,

            449, 456, 457, 464, 465, 472, 473, 480, 481, 484, 485, 488, 489,

            490, 491, 494, 495, 496, 497, 498, 499, 504, 505, 506, 507, 526,

            527, 637, 638, 639, 682, 683, 684, 670, 671, 678, 679]

  Here   = [78, 79, 84, 86, 87, 92, 93, 94, 95, 96, 98, 105, 109, 110, 111,

            112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123, 125, 126,

            127, 134, 135, 140, 142, 143, 144, 146, 148, 149, 150, 151, 336,

            337, 338, 339, 340, 342, 343, 344, 345, 346, 347, 348, 350, 351,

            352, 353, 354, 355, 356, 357, 358, 359, 363, 364, 365, 366, 367,

            368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380,

            381, 382, 383, 432, 433, 434, 435, 436, 437, 438, 439, 442, 444,

            445, 447, 450, 451, 452, 453, 454, 455, 458, 459, 460, 461, 462,

            463, 466, 467, 468, 469, 470, 471, 474, 475, 476, 477, 478, 479,

            486, 487, 502, 510, 511, 516, 517, 518, 524, 525, 536, 537, 538,

            539, 540, 541, 542, 543, 552, 553, 554, 555, 556, 557, 558, 559,

            568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580,

            581, 582, 583, 584, 585, 586, 587, 588, 589, 641, 648, 649, 650,

            651, 652, 653, 654, 655, 662, 663, 664, 665, 666, 667, 668, 669,

            675, 676, 677, 680, 681, 688, 689, 690, 691, 692, 696, 697, 698,

            699, 700, 701, 712, 713, 714, 715, 716, 717, 718, 719, 726, 727,

            734, 735, 742, 743, 748, 749, 750, 751]

end

  

 

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

# ** Game_Player

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

#  This class handles maps. It includes event starting determinants and map

# scrolling functions. The instance of this class is referenced by $game_map.

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

 

class Game_Player < Game_Character

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

  # * Alias Methods

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

  alias glitch_unusual_update_nonmoving update_nonmoving

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

  # * Processing when not moving

  #     last_moving : Was it moving previously?

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

  def update_nonmoving(last_moving)

    if not $game_message.visible and Input.trigger?(Input::C)

      check_tile

    end

    glitch_unusual_update_nonmoving(last_moving)

  end

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

  # * Check Tile

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

  def check_tile

    if @direction == 2

      tile_data = $game_map.data[@x, @y + 1, 2]

    elsif @direction == 4

      tile_data = $game_map.data[@x - 1, @y, 2]

    elsif @direction == 6

      tile_data = $game_map.data[@x + 1, @y, 2]

    elsif @direction == 8

      tile_data = $game_map.data[@x, @y - 1, 2]

    end

    return if tile_data == nil || tile_data == 0

    $game_message.face_name = $game_actors[1].face_name

    if Unusual::Inside.include?(tile_data)

      text = Vocab::Unusual + Vocab::Inside

      $game_message.texts.push(text)

    elsif Unusual::Here.include?(tile_data)

      text = Vocab::Unusual + Vocab::Here

      $game_message.texts.push(text)

    end

  end

end

Next, to change how many lines, you've got to make another line like this:

Code:
$game_message.texts.push(text)
Where text (inside the parentheses) is the string of text you want him to say. (So, inside quotes) Each time you do that, it should add a line to what he is saying. I've got the original set of lines like this code near the bottom.
 
mk1995":rz1mq0po said:
Damnit... It doesn't work. The game doesn't crash, but when I press Enter (or any other Action Button), my main character doesn't say anything.

Are you doing it on one of the predefined objects? Or are you doing it on the ground? I had just tested it before posting, and it worked.
 
Never mind. It does work, after all. By the time I posted my previous message, I only tried it on the floor.

However, I still have some problems:
1) The Face Set the Script uses is OK, but it's the wrong face! Is it possible to change it, somehow?
2) I still have no idea how to add another line. Could you give me a more specific description, please?
 
Under this line

$game_message.face_name = $game_actors[1].face_name

try adding another one...

$game_message.face_index = $game_actors[1].face_index

If it fails, then take a look at "Show Text" method in Game_Interpreter, it should tell you what the actual attribute / public instance variable should be.
 
mk1995":drm03mgu said:
Never mind. It does work, after all. By the time I posted my previous message, I only tried it on the floor.

However, I still have some problems:
1) The Face Set the Script uses is OK, but it's the wrong face! Is it possible to change it, somehow?
2) I still have no idea how to add another line. Could you give me a more specific description, please?

To change the face it uses, you have to change the one in the following code to the number of the actor who's face you want to show.

Code:
$game_message.face_name = $game_actors[1].face_name

Also, to add another line, you have to add another copy of this line, where you change text to "Your text here." (You add this line right after the lines already in the script that look exctly the same. So, you add it after what is currently lines 87 and 90. Currently, adding the code I mentioned would print the same line twice. If you cange text to "Your text here." the second line will be Your text here.)

Code:
$game_message.texts.push(text)
 

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