Calling a specific scene index?

Discussion in 'Learning Ruby and RGSSx' started by SaburoX, Dec 5, 2017.

  1. SaburoX

    SaburoX Veteran

    Messages:
    63
    Likes Received:
    6
    I know I can load a scene in VX Ace with the script call SceneManager.call(X).
    So my question is, how do you call a scene but jump to a specific index or category, or otherwise automate moving in that scene?

    I'm trying to put together a tutorial sequence, and I can load Scene_Item. That'll load the item menu as intended, and the cursor will be on the first option in the index (items). How can I move it to the second index listing (weapons)?

    Assuming there's a way to do that, a follow question would be if the method applies to stuff that might be actor specific like skills.
     
    #1
  2. MobiusXVI

    MobiusXVI Game Maker

    Messages:
    292
    Likes Received:
    66
    First Language:
    English
    So you actually don't want to load Scene_Item. I know that sounds weird but stay with me. See the "Scene" is responsible for two main things responding to user input and drawing graphics to the screen. That's an incredibly simplified view of it, but it helps to think of that way in this instance because what you really want is to use Scene_Item's graphics but not respond to normal user input.

    I would recommend you make your own Scene called like Scene_Item_Tutorial or something. You can reuse Scene_Item's windows and everything but have your code driving the displays. In fact, you might even be able to subclass Scene_Item to have it load everything for you.
     
    #2
  3. SaburoX

    SaburoX Veteran

    Messages:
    63
    Likes Received:
    6
    I thought that might be the case. I actually do know of a Tutorial Scene script, but it's got a conflict with the Scene Interpreter script I'm already using where the message windows don't get disposed properly and start behaving strangely. I might've been able to fake the effects with just the latter, but then the question is how to take control of the menu cursor from the player.
     
    #3
  4. MobiusXVI

    MobiusXVI Game Maker

    Messages:
    292
    Likes Received:
    66
    First Language:
    English
    Yea, that takes a bit of digging to figure out. What we want to do is trace through the code to find where it takes user input, and then see what it does to move the cursor. That will let us both ignore the user's input and move the cursor ourselves.

    So first, start at Scene_Item and look for the 'update' method. That gets called every frame. Well, it doesn't have one, so look in the superclass Scene_ItemBase. It also doesn't have one, but if you continue the chain, you'll reach the base class Scene_Base which calls 'update_basic' which calls 'update_all_windows'.

    Ok, so if the scene isn't handling input, then the windows probably are. It's pretty obvious that we're probably looking for a 'Window_Item' but just to be sure we can go back to the Scene_Item and see which windows it uses. The scene creates two windows: Window_ItemList and Window_ItemCategory. So now let's investigate those.

    As before if we go looking for an update method, we won't find one but we can search the superclasses again. This leads us to Window_Selectable. Scrolling through it we find the 'update' method, which calls 'process_cursor_move'. Success! This method takes the user input and then calls methods to actually move it. So with this knowledge, we can now write our own scene with our own version of Window_ItemList that overwrites this method and restricts user input to nothing.
     
    #4
  5. SaburoX

    SaburoX Veteran

    Messages:
    63
    Likes Received:
    6
    I can actually restrict user input with eventing. When I said "take control" I meant forcing the cursor to move, which I assumed has something to do with the cursor_down or the input.trigger? codes.
    I guess I'm just surprised there's no simple script call for that and that I'd need to make something completely from scratch for such a simple thing. Thanks for the advice, though!
     
    #5
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy'

    Messages:
    13,142
    Likes Received:
    2,069
    Location:
    Philippines
    First Language:
    Tagalog
    You don't actually need to move in the "scene"... The item selected is actually a part of Window_ItemList (if I remember correctly), so you just need to call the instance of Window_ItemList in that scene, and then make it call the .select(index) method. The only problem here is that most window member of scenes are actually private so you normally can't access them if you're calling from outside of that scene.

    How you do it would also depend on how you're doing it. For example, normally you can't use an event to do it since events don't actually run inside the menu. Like if for example you used an event to call the Item scene, the next stuff in your event won't actually run until you exit the menu.

    Just for reference, the script call that you'd want is this (assuming you're not calling it from directly inside the Scene_Item class)

    Scene_Manager.scene.item_window.select(index)

    but item_window is a private member of the scene so you would need to add this script first into your scripts window, else it would error as it won't be able to find item_window

    class Scene_Item
    def item_window
    return @item_window
    end
    end

    As I said above though, you might not be able to use that script call at all if you're calling this via an event, unless you have a Scene Interpreter script which would allow events to run inside scenes that aren't Scene_Map or Scene_Battle

    PS: I re-read your post and realized you don't want to move in the item_window but rather in the category window. Use this instead

    Scene_Manager.scene.category_window.select(index)

    and this script

    class Scene_Item
    def category_window
    return @category_window
    end
    end
     
    Last edited: Dec 9, 2017
    #6

Share This Page