Ruby/RGSSx questions that don't deserve their own thread

Discussion in 'RGSSx Script Support' started by Mr. Bubble, Mar 14, 2012.

  1. Engr. Adiktuzmiko

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

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    Youre gonna place it on materials section too, just that the code needs to run somewhere else, like as posted above...

    If you place a code outside of any method, that would run during set up before any other scripts start running, which was the cause of your problem...
     
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,921
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    What is it that you're actually trying to achieve? I get the feeling that you're just doing it in the wrong place - so rather than forcing a way to let you do it, it would be better to find out what you're actually trying to do (why are you setting a variable in script rather than in a startup event?) so you can do it the right way.
     
  3. sokita

    sokita Crawling back to the surface Veteran

    Messages:
    198
    Likes Received:
    29
    Location:
    Indonesia
    First Language:
    Indonesian
    Script call for self switches is $game_self_switches[[map_id,id,"letter"]] = value. So, if I want to set all letter to false, I must write it 4 times (for A to D). Just wondering, is there a way to make this shorter without making a method inside Game_Interpreter class?
     
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,921
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    ['A', 'B', 'C', 'D'].each do {|switch| $game_self_switches[[map_id, id, switch]] = false


    Assuming you're replacing map_id and id with actual numbers, because they would not work in a script call. You'd have to use $game_map.map_id and @event_id for the "current" event.
     
    sokita likes this.
  5. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    Actually, he/she can use

    ['A','B','C','D'].each{|ss|$game_self_switches[[@map_id, @event_id, ss]]}if he/she wants it shorter
     
    Last edited by a moderator: Aug 15, 2015
    sokita likes this.
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,921
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    oh yeah, you don't need the "do" with {}, but other than that, what you put is exactly what I put, except you used ss instead of switch as the variable name. And you didn't assign it a value ;)
     
  7. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    Note the @map_id.

    You noted that he/she can use $game_map.map_id, but Game_Interpreter has a public instance variable @map_id.

    No need for $game_map.map_id

    That's the reason why I posted, and not because of do and ss. And yeah, I forgot to add the initial value, oops :)
     
    Last edited by a moderator: Aug 15, 2015
  8. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    What am I doing wrong?

    Problem:

    class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * alias: initializes back variable #-------------------------------------------------------------------------- alias cdr_rows_initialize initialize def initialize(actor) cdr_rows_initialize(actor) if actor.back_row? @back = true else @back = false end end  
    Error:

    [​IMG]
    back_row definition:

    #==============================================================================# ** RPG::BaseItem#==============================================================================class RPG::Actor #-------------------------------------------------------------------------- # * new method: check initial back row #-------------------------------------------------------------------------- def back_row? return !(note =~ CDR_ROWS::REGEXP::BACK_ROW).nil? endend
    CDR_ROWS::REGEXP::BACK_ROW = /<(?:back_row)>/i

    Thanks guys :)
     
  9. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    677
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    Question - How to get amount of party members?

    For example - there are 2 actors in party > output 2; there are 5 actors in party > output 5

    What I need that for? - setting dynamic window size based on current amount of party members.

    IDK, something like $game.party_members.amount < translate that to Ruby language.

    Thank you in advance.
     
    Last edited by a moderator: Aug 16, 2015
  10. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    @Rikifive

    You were close

    Code:
    $game_party.members.size
     
    Last edited by a moderator: Aug 16, 2015
    Rikifive likes this.
  11. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    677
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    Ahaha, thank you! xD
     
    Last edited by a moderator: Aug 16, 2015
    Alyon93 likes this.
  12. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    @Alyon

    Because in the initialize, the actor is a parameter.

    Try changing that to

    Code:
    def initialize(actor_id)
     
  13. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    Ok it's working even if I don't actually understand why.

    The more I think I'm starting to learn scripting, the more I lose hope on it!  :D

    Cheers Mate  :)
     
  14. metronome

    metronome Veteran Veteran

    Messages:
    348
    Likes Received:
    142
    First Language:
    English (Sure!)
    Questions:


    What is the script call to turn all switches and self switches in the game off?


    Is it:

    And then, what is the script call turn all variables in the game into 0?


    is it:

    I want to restart the whole game from the start when the game is ended without going to


    menu screen, and I don't want to use New Game+ script (too confusing and I am not into


    adding more scripts into script editor). That's why I ask these questions.


    Thanks for at least reading~~!!
     
    Last edited by a moderator: Aug 16, 2015
  15. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
    I've got another question:

    Is it possible to extend "an ally(dead)" scope so that I can target a member in another state too? 

    I'm doing a skill with wich a character may help the others while in danger. Right now he works as a simple revive skill, but I'd like to use it also for traps(like a character caught in a spider net or something).

    I might use it in "an ally" scope but I don't like the idea to being able to select other members too.

    I guess if it's not possible I will keep the "an_ally" scope but I'm really curious about it actually.
     
    Last edited by a moderator: Aug 16, 2015
  16. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    @metronome

    I think it can be done like that.

    But, if it does not work, paste the error here, and we may be able to help you

    @Alyon

    It CAN be done, but I think it is not in the scope of RGSSx Script Supporters.

    Try posting this to RGSS3 Script Requests, because this script requires a bit more work than just a few lines of code (first some regexps, then Scene_Battle...)

    That's just my opinion, maybe when you post there some moderator will redirect your post to this forum, and I'm sorry in that case.

    (Sorry, moderators, if I led him to a wrong forum)
     
    Last edited by a moderator: Aug 16, 2015
  17. Alyon93

    Alyon93 Veteran Veteran

    Messages:
    62
    Likes Received:
    2
    Location:
    Milano(MI), Italy
    First Language:
    Italian
    Primarily Uses:
    N/A
     Ok mate I'll try there. I thought it would have been easy actually. 

    Thanks anyway :)
     
  18. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    677
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    Question: Is it possible to make a condition, where game checks which window it is?

    Example: Something like "if SceneManager.scene_is?(Scene_<Scene>)" but to not check the whole scene, but one window.

    What I'm trying to achieve: I'm using MOG menu cursor and I would like to change its position when moving to actor selection window. In general - the cursor is on the left side ~ I want to move it to the right side when going to window, where I'm selecting actors (through 'formation' 'equip' etc. commands).

    Thank you in advance.
     
  19. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    It can't be really done that easy.

    But it can be done like this :

    Imagine you have a scene with @actor_window, @item_window, @skill_window, @some_window and @choice_window (just an example, no need for that much windows, though)

    So, if you want to check is Actor Window active you do @actor_window.active

    For Choice Window it would be @choice_window.active

    There isn't really a variable of currently active window, because more windows at once can be active.
     
    Last edited by a moderator: Aug 16, 2015
  20. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    677
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    So.. for actor status window should I try something like this?

    if SceneManager.scene_is?(Scene_Menu) && if @actor_window.active < lol will this work? xD

    cursor to the right

    else

    nope, stay on the left.

    end

    ?

    [​IMG]

    I tried

    if SceneManager.scene_is?(Scene_Menu) if @actor_window # because .active caused crash. righty else lefty endelse also leftyendbut it didn't work. =P

    So I think it's kinda impossible? =P
     
    Last edited by a moderator: Aug 16, 2015

Share This Page