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.

Completely stuck

Ok... I've looked through the forums and various tutorials, and haven't been able to find quite the answers I'm looking for. Basically, the script editor has me a bit mystified.
Now, I understand the concept of scripting, and I have been looking at enough tutorials that I'm starting to get some of the language, but I guess you could say I have no idea what to actually do with any of it.
An example of what I mean: let's say I want to use a custom message window system in my game, so I can, say, have a character's name and face portrait appear next to the text boxes during dialogue. So I find one that sounds like it does what I want and I download it. Great.

Now what?

Do I just copy the whole script and paste it in somewhere in the editor in my game? Where? Does it go in one of the existing categories (i.e. "Game_System" or "Window_Message", etc.) or do I make a new one? What do I do with the already existing scripts that deal with message windows?

Or, let's say (along a somewhat similar line, I suppose) I want to make it so that when the player brings up the status menu, it will show face portraits for each character next to their name, instead of the default way of showing the sprites. Where would I find the scripts that need to be changed to do this? OR...is it not actually a matter of changing an existing script, but of making a completely new script? For this one, I even tried looking at the sample game you can get off Enterbrain's website (KNight's Blade)...since it shows face portraits in the menu, I thought I'd try to track down where in that game's scripts there is SOMETHING different from the standard...something that makes it show those faces, but I couldn't find anything. Of course, that most of the comment lines were in Japanese didn't help me on that one, I'm sure.
So, to make a long story short, this very fundamental part of scripting, for whatever reason, has completely eluded me...it's like I get what scripts are, I just have no clue what to do with them. I don't necessarily expect anyone to give me a complete, step-by-step, hand holding walkthru of how to script, I just need some general guidelines on concept of where things go. Sorry it's such a long post, but I wanted to make sure I accurately conveyed my problem. Much thanks and cookies to anyone who can help me figure this out! ;)
 

OS

Sponsor

Hmmm...in order to get the Window to change, just make a new script between Main and the other default scripts. The script will automatically do what needs to be done. You shan't need to alter other scripts unless the new script has instructions to do so. Just follow instructions in the scripts and you should be able to figure everything out.

As for learning scripting, try Ruby Forge, Tutorials, and Google. If all else fails, join the Academy! Peace!
 

Jared

Member

The simple model is following:
- The Scene classes have the control over a part in your game, which doesn't overflow in other Scenes. Example: The statusmenu, the battle and the map are own scenes, because there are no elements from the menu in the battle and no elements from the map in the menu.
- A scene consist usually of the important elements: main and update
- main has this structure:
Code:
def main
  #Initialize instances
  @bla = Bla.new
  @my_window= Special_Window.new
  #...
  #Update-Loop
  loop do
    #...    
  end
   #terminate instances if neccessary
   @bla.terminate
   @my_window.dispose
end

Other elements in the script editor are Game-classes, Windows, Sprites and Spritesets.


If you want to add a new feature, you have first to find it's Scene. There, you have to add a new instance in the initializing-part of the main method, you have to update the feature in the update method and maybe you must terminate the feature in the terminate-part of main (especially graphics have to be disposed). Sometimes it's better to add a feature in a existing instance of a scene, because the feature belongs to this instance.
You want to make character portraits in your menu. You could make a new instance @character_portraits in the way I described. But the portraits are shown in the mini status window, where the character-graphics are shown by default. So it would be better, you add your feature in the Window_MenuStatus class.

The most windows have following structure:
- initialize --> initializing of the instances
- refresh --> clear and show the graphics
- update --> update special effects in the graphics, when neccessary
- dispose --> dispose the graphics

The graphics are shown in the refresh method, so you have to add your feature here.
Code:
def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 80) #LINE WHICH NEED AN EDIT
      draw_actor_name(actor, x, y)
      #....
    end
  end
This window shows the status of your heroes. The heroes are instances of the global $game_party object, so you get there informations from everywhere. The method draw_actor_graphic is responsible for the drawing of the hero. You can write your own draw_actor_portrait method and replace this new method with the old.
Write the new method in the Window_MenuStatus class (or in the Window_Base class, if you want to use this method for other windows, too).

Because there are no information about a faceset in the Game_Actor classes, you have to find an own way to explain ruby, which graphic it should use for which hero. Example you can import the facesets with the same name like the hero or the battlers.

As you want, I will not write the whole scripts. But I hope, I could give you an imagine how to add new features in the script-complex of the project.
 
Ahh...ok, this is starting to make more sense. I hadn't noticed the "Main" before. Of course, I still have a long way to go before I could say that I really "know how to script" but now I don't feel so lost on the basics. And I've now been able to add scripts to my game that show faces during dialogue and on the menu. Thanks Jared and OptimistShadow! ;)
 

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