Learning to script

So I'm moderately knowledgeable on coding and Ruby. I've been going through various courses (online and books) and put together various simple applications (outputs on command line prompts, nothing too fancy). But I really want to learn to do something with it, to go the next step and create actual applications that people will pick up and use.

That's where RPG Maker comes in! It's all there, ready to access and start tinkering with as long as you have the Ruby knowledge. I was hoping to use this forum to learn from some more experienced coders on how to go about learning to script - not just learning about variables this, methods that, but how to use the nuts and bolts to actually build something exciting. I've been poring over the script manager in RMVXA and the pieces are slowly coming together about all the constituent parts work together to make the game actually run.

Resources on this seem a little thin on the ground (or maybe I'm not looking hard enough?) so I created this thread with the hope that others in my position will come forth and we can learn to together - people who have some (a little?) coding knowledge, looking to make the next step.

So, to kick us off; bassfire compiled a list of youtube videos made by the wonderful gubid who's teaching us to script. This was exactly the level I was looking at, and I've been working through the videos. The best ones, however, seem to be for RMVX, not Ace, so there's some conversion that needs to be done to make his scripts work, and I was hoping someone would be able to point me in the right direction.

In this video, he shows how to make a window pop up that just shows a character's face (in order to teach us how classes and inheritance works). When I follow his tutorial, however, I can make the window appear, but it won't dispose. Here's the script as written in the manager:

class Window_Mine < Window_Base def initialize super(0, 0, 320, 240) actor = $game_actors[1] x , y = 5, 50 draw_actor_face(actor, x, y) endendclass Scene_Mine < Scene_Base def start @my_window = Window_Mine.new end def update @my_window.update if Input.trigger?(Input::C) $scene = Scene_Map.new end end def terminate @my_window.dispose endendAnd in the game we create an event with the following scipt call in it:

SceneManager.call(Scene_Mine)As mentioned, when you activate the event, it creates the window as expected but it will not go away. I'm guessing it's either something to do with the input not triggering ("if Input.trigger?") or the "def terminate" method not set up correctly. If someone knows what else I need to do to get it to work as in the video, I'd be highly appreciative.
The code is fine but some functions has changed between Vx and Ace like the "SceneManager", on Vx version is not existing when you want to change scene you change the global variable $scene, in Ace you need to call  "SceneManager.goto(Scene)" also the input has changed you can check the Ace help file to help you Input section, and you should add "super" in all your methods it execute code of the parent class (if you don't put it in update for example your update is not gonna work)

Code:
class Window_Mine < Window_Base  def initialize    super(0, 0, 320, 240)    actor = $game_actors[1]    x , y = 5, 50    draw_actor_face(actor, x, y)  endendclass Scene_Mine < Scene_Base  def start    super    @my_window = Window_Mine.new  end  def update    super    @my_window.update    if Input.trigger?(:C)      SceneManager.goto(Scene_Map)    end  end  def terminate    super    @my_window.dispose  endend
Thanks a lot! Using your suggestions, I was able to make it work.

Continuing on to the next video I can see there are a lot of changes between RGSS2 - 3. I'm currently studying the data manual built into RM to understand what I need to do to. Think this is going to be quite a learning curve.
Wondering if anyone can help me out with this.

I'm attempting to create a simple script that allows you to store an item inside an event so it can later be retrieved.

So when you interact with the 'storage' event it would open the Scene_Item, but after selecting the item instead of using it, it would return the item's data and hold it in a variable. So I'd just need to create a new custom event that inherits from Scene_Item but has a new use_item def. That's fine. It's how to return and remember the item in question I'm stuck on.

How would I go about doing this? Can I create the variable inside the event itself or would it need to be some kind of global variable? (I understand global variables are generally frowned upon.)

Any help is appreciated, thanks in advance.
You could for example make a new variable in the Game_System class:

class Game_System alias_method🙂old_initialize, :initialize) def initialize old_initialize @storage = [] end def add_to_storage(item) @storage.push(item) unless @storage.include?(item) end def remove_from_storage(item) @storage.delete(item) if @storage.include?(item) endendThen you could just call $game_system.add_to_storage and pass the item as argument.

Or you could look into the Game_Party class and see how they handle the inventory thing.

If you think about it, you would just need to replicate that behaviour somehow.

Original thread: https://forums.rpgmakerweb.com/threads/learning-to-script.36996/