Scripting assistance please

Discussion in 'RGSSx Script Support' started by CodeHunterEx, Nov 19, 2018.

  1. CodeHunterEx

    CodeHunterEx Hunter of the Perfect Code Veteran

    Messages:
    133
    Likes Received:
    62
    Location:
    Coder's Tech Cave
    First Language:
    English
    Primarily Uses:
    RMVXA
    I am looking for help with using Common Event calls and Move Routes in RGSS3 Scripting.

    $game_temp.reserve_common_event(4)
    ^ That is used to call an event, but does it? ^

    Also if I have text message in my scripts to see what is happening, it seems to run by them without stopping to breathe.

    I can use wait() to slow down a bit and that will help, but it still seems to skip the common event calls.

    "SceneManager.scene.wait(30)" gives an error when used. I am missing something.

    Also, while I am at it, how does this command work: x.times { Fiber.yield }
    Update: ^ Skip that ^

    Can you give any examples for any of these requests?
     
    Last edited: Nov 19, 2018
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,584
    Likes Received:
    11,300
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Perhaps you should start with explaining what it is you're trying to do, and how you're trying to do it. We can spend a lot of time answering your questions only to not have it work, and then discover that it was the wrong approach entirely.
     
    #2
  3. CodeHunterEx

    CodeHunterEx Hunter of the Perfect Code Veteran

    Messages:
    133
    Likes Received:
    62
    Location:
    Coder's Tech Cave
    First Language:
    English
    Primarily Uses:
    RMVXA
    > Call Common Event <

    I am learning scripting and I have the following:
    if $game_variables[75] == $game_variables[1]
    $game_variables[69] = 1
    $game_temp.reserve_common_event(4)

    $game_variables[31] = $game_variables[1]
    end

    When I call that it seems to just pass it by as if nothing is going on. If I add a wait 'wait(30)' or even '30.times { Fiber.yield }' to slow things down, still it doesn't seem to work for each condition.

    At the end I have it call a final time and that seems to work.

    > Move Route <

    For move route I am trying to include that into the script without using the call if it will work/work better. I just haven't been able to get it to work using the information here:
    https://forums.rpgmakerweb.com/index.php?threads/script-call-collection-for-vxace.25759/#entry247427

    What the Common Event does is quite simple and it can be optimized in code. It get the Region location of the character and then compares that with the location it needs to move to. If the location value is smaller, then it calls a simple 'Move Route' that just moves character left until it is on the spot it needs to be. If the value is larger, it goes right.

    See here:
    MoveTeacher.png

    What isn't shown is a move route that has the character turn 'up' or 'down' depending on the position value. Basically up when showing the letters and down at the end when she returns back to the center position.

    Hopefully this explains what I am trying to do pretty well. Feel free to keep asking if you need more information.
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,584
    Likes Received:
    11,300
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Common Event:
    how/where are you doing that call?

    Move Route:
    are you using the move route on event 30 or on another event? Where are you updating variable 69?
    Can you show a screenshot of your map, with the event, and the region layer visible?

    I don't think any of these things would be done better as script calls - there aren't enough commands or iterations there to make using events cause any kind of lag.
     
    #4
  5. CodeHunterEx

    CodeHunterEx Hunter of the Perfect Code Veteran

    Messages:
    133
    Likes Received:
    62
    Location:
    Coder's Tech Cave
    First Language:
    English
    Primarily Uses:
    RMVXA
    Yes, event 30 is the event that is getting moved.

    Here is the map:
    GameroomMap.png

    Here is the full script:
    # ----------------------------------------
    # this script will get the letter chosen
    # by the player and check to see if it is
    # in the puzzle. if the letter is found,
    # it will display it.
    #
    # script by code hunter
    # ----------------------------------------

    class Game_Interpreter

    def scan_board
    $game_temp.reserve_common_event(7)
    end

    def check_board
    # Get the region code (1-13) the player is on
    $game_variables[75] = $game_player.region_id

    # Get players direction
    # Up = A-M ( 1-13)
    # Down = N-Z (14-26)
    $game_variables[65] = $game_player.direction

    # player facing down so add 13 to the value
    if $game_variables[65] == 2
    $game_variables[75] +=13
    end

    $game_variables[69] = 0
    $game_variables[70] = 8
    $game_variables[68] = 19

    if $game_variables[75] == $game_variables[1]
    $game_variables[69] = 1
    $game_temp.reserve_common_event(4)
    scan_board
    10.times { Fiber.yield }

    $game_variables[31] = $game_variables[1]
    end

    if $game_variables[75] == $game_variables[2]
    $game_variables[69] = 2
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[32] = $game_variables[2]
    end

    if $game_variables[75] == $game_variables[3]
    $game_variables[69] = 3
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[33] = $game_variables[3]
    end

    if $game_variables[75] == $game_variables[4]
    $game_variables[69] = 4
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[34] = $game_variables[4]
    end

    if $game_variables[75] == $game_variables[5]
    $game_variables[69] = 5
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[35] = $game_variables[5]
    end

    if $game_variables[75] == $game_variables[6]
    $game_variables[69] = 6
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[36] = $game_variables[6]
    end

    if $game_variables[75] == $game_variables[7]
    $game_variables[69] = 7
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[37] = $game_variables[7]
    end

    if $game_variables[75] == $game_variables[8]
    $game_variables[69] = 8
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[38] = $game_variables[8]
    end

    if $game_variables[75] == $game_variables[9]
    $game_variables[69] = 9
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[39] = $game_variables[9]
    end

    if $game_variables[75] == $game_variables[10]
    $game_variables[69] = 10
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[40] = $game_variables[10]
    end

    if $game_variables[75] == $game_variables[11]
    $game_variables[69] = 11
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[41] = $game_variables[11]
    end

    if $game_variables[75] == $game_variables[12]
    $game_variables[69] = 12
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[42] = $game_variables[12]
    end

    if $game_variables[75] == $game_variables[13]
    $game_variables[69] = 13
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[43] = $game_variables[13]
    end

    if $game_variables[75] == $game_variables[14]
    $game_variables[69] = 14
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[44] = $game_variables[14]
    end

    if $game_variables[75] == $game_variables[15]
    $game_variables[69] = 15
    $game_temp.reserve_common_event(4)
    60.times { Fiber.yield }

    $game_variables[45] = $game_variables[15]
    end

    if $game_variables[69] == 0
    $game_message.background = 0
    $game_message.position = 1
    $game_message.add("Not Found")

    $game_variables[77] += 1
    else
    $game_message.background = 0
    $game_message.position = 1
    $game_message.add("Found")

    $game_variables[76] += 1

    $game_variables[69] = 8
    $game_variables[68] = 16
    $game_temp.reserve_common_event(4)
    end

    end

    end

    The script is called each time the player selects a letter.

    The script is used to check if a letter is in the puzzle, and if so, saves the location where the letter is and then calls the common event that moves the character left/right (or not at all if centered).

    Region map can be seen in my Region Restriction post:
    https://forums.rpgmakerweb.com/index.php?threads/npc-region-restriction-tutorial.102051/
     
    #5
  6. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,612
    Likes Received:
    10,514
    First Language:
    English
    Primarily Uses:
    RMVXA

    I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,348
    Likes Received:
    6,454
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @CodeHunterEx
    Common events can't be processed everywhere or anytime, they only work when the game interpreter is active for them.
    To compensate this, the function "reserve" common event places the true call to it into a queue of the main game loop to be processed as soon as the game interpreter becomes active next - which is never while a pure script function llike yours is still active, but later.
    Some background info about the game loop is in my bughunting tutorial if you're interested in that.
     
    #7

Share This Page