[Ace] Useful Script Call Reference

Discussion in 'RPG Maker VX Ace' started by Valsazaar, Mar 17, 2014.

  1. Valsazaar

    Valsazaar Warper Member

    Messages:
    4
    Likes Received:
    4
    First Language:
    English
    Trying to compile a useful list of native / semi native functions for scripting. Can't seem to find a good single page resource for this anywhere. Will add more as I progress. I am aware of the 14 page monstrosity floating around with content spread all over the place.

    REGION MANIPULATION

    setTileRegion(x,y,newID)

    description: extends the game map class to be able to set tile regions in real time

    typical usage: $game_map.setTileRegion(x,y)

    class Game_Map  def setTileRegion(reg_x,reg_y,reg_id)        if reg_id > 63 || reg_id < 0      reg_id = 0    end        @thirdvalue = "%14b" % self.data[reg_x, reg_y, 3]           # binary split of the two elements    @bLEFT = @thirdvalue[0,6] # REGION ID IN BINARY    @bRIGHT = @thirdvalue[6,8] # SHADOW ID IN BINARY        @bLEFT = "%6b" % reg_id        @newvalue = @bLEFT.to_s + @bRIGHT.to_s    @newvalue = @newvalue.to_i(2)        self.data[reg_x, reg_y, 3] = @newvalue      endend

    getTileRegion(x,y)

    description: extends the game map class to return the tile region at coordinate x,y on the map loaded into game map

    typical usage:

    @variablename = $game_map.getTileRegion(x,y)



    class Game_Map  def getTileRegion(reg_x,reg_y)        # gets a 14 bit long binary string from the map data array @thirdvalue = "%14b" % self.data[reg_x, reg_y, 3]           # binary split of the two elements    @bLEFT = @thirdvalue[0,6] # REGION ID IN BINARY    @bRIGHT = @thirdvalue[6,8] # SHADOW ID IN BINARY # converts the binary string back to an integer and returns    return(@bLEFT.to_i(2))      endend


    getShadowID(x,y)

    description: extends the game map class to return the shadow tile ID at coordinate x,y on the map loaded into game map

    typical usage:

    @variablename = $game_map.getShadowID(x,y)



    class Game_Map  def getTileShadowID(reg_x,reg_y)     # gets a 14 bit long binary string from the map data array    @thirdvalue = "%14b" % self.data[reg_x, reg_y, 3]           # returns binary split of the two elements    @bLEFT = @thirdvalue[0,6] # REGION ID IN BINARY    @bRIGHT = @thirdvalue[6,8] # SHADOW ID IN BINARY # converts the binary string back to an integer and returns    return(@bRIGHT.to_i(2))      endend


    MAP MANIPULATION

    getTileIDByLayer(x,y,layer)

    description:

    returns the tile ID stored in the map database. These are the internal ID's that the engine uses to refer to tiles. Autotiles can have anywhere up to 50 variants! More useful for checking if scenery items are ona  tile than checking if a ground type is of a certain variety. Layer0 is the ground layer, Layer1 is the mask layer that overlays Layer0's and Layer2 is the object layer for A5-B,C,D,E.

    typical usage:

    @variablename = $game_map.getTileIDByLayer(x,y,layer)

    class Game_Map def getTileIDByLayer(x,y,layer) return(self.data[x,y,layer]) endendsetTileIDByLayer(x,y,layer,tile_ID)

    description:

    sets the tile ID of a specified tile on the map to temporarily display on screen. This is temporary only because it does not update the saved map data, only the copy in memory that is temporary. Changing map, loading,saving etc will all refresh this value and cause the map to revert to its state in the game editor.

    tile_ID is the internal ID's that the engine uses to refer to tiles. Autotiles can have anywhere up to 50 variants! More useful for temporary spell effects, puzzles than permenant world changes.

    Layer0 is the ground layer, Layer1 is the mask layer that overlays Layer0's and Layer2 is the object layer for A5-B,C,D,E.

    typical usage:

    $game_map.setTileIDByLayer(57,32,1,1069)

    class Game_Map  def setTileIDByLayer(x,y,layer,tile_ID)    self.data[x,y,layer] = tile_ID  endendSAVABLE MAP MANIPULATION

    Strongly recommend the following script:

    Title: Tile Swap
     Author: Tsukihime, Rycochet

    (just google it, better than me posting dead links here, fantastic script I couldnt recommend more highly)

    combined with the below additional command:

    changeTileByInternalID(map_id,x,y,layer,intID)

    description:

    sets the tile ID of a specified tile on the map_id number permenantly to another value.

    The script linked above does 99% of the heavy lifting here as far as retaining data between games, autotiles etc.

    tile_ID is the internal ID's that the engine uses to refer to tiles. Autotiles can have anywhere up to 50 variants!

    Layer0 is the ground layer, Layer1 is the mask layer that overlays Layer0's and Layer2 is the object layer for A5-B,C,D,E.

    typical usage:

    $game_system.changeTileByInternalID($game_map.map_id, x, y, layer, tile_ID)

    dependency:

    Title: Tile Swap
     Author: Tsukihime, Rycochet


    Code:
    class Game_System  def changeTileByInternalID(map_id,x,y,layer,intID)    initialize_pos_list(map_id, layer)        tid = intID        @swapped_pos_tiles[map_id][layer][y] = [] if @swapped_pos_tiles[map_id][layer][y].nil?        @swapped_pos_tiles[map_id][layer][y][x] = tid        $game_map.load_new_map_data  endend
     
    Last edited by a moderator: Mar 17, 2014
    #1
  2. C-C-C-Cashmere (old)

    C-C-C-Cashmere (old) Resident Weirdo Veteran

    Messages:
    834
    Likes Received:
    341
    First Language:
    English
    What the heck, this is so useful. More please lol.

    Thank you!
     
    #2
  3. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,246
    Likes Received:
    2,052
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Okay.

    You got my attention!

    What are the Terms of use for these scripts?  :)
     
    #3
  4. Long Lost Hero

    Long Lost Hero Veteran Veteran

    Messages:
    38
    Likes Received:
    6
    First Language:
    English
    Is this used for allowing the player to change the map tiles as they play the game? Such as destroying walls or blowing a hole in the ground or building a house?
     
    #4
  5. Bex

    Bex Veteran Veteran

    Messages:
    792
    Likes Received:
    132
    First Language:
    German
    The POS-Revert command of Tsukuhimes Script is Buggy.

    Without that function the Script is Awsome but only as half as good it could be.

    Can someone fix the Bug in that Script?
     
    #5
  6. Amegatron

    Amegatron Warper Member

    Messages:
    3
    Likes Received:
    1
    Location:
    Saint-Petersburg, Russia
    First Language:
    Russian
    Hm, there is already $game_map.region_id(x,y) for that :)
     
    #6
  7. daniacea

    daniacea Maker Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Ohio
    First Language:
    English
    I thought I would add this here. I wanted to add it to script call equivalents of events but that post is locked. 

    To start a game timer from a script call;

    $game_timer.start(600)

    Each unit of 60 equals 1 second, so this example would start a timer with 10 seconds. 
     
    #7
  8. Bex

    Bex Veteran Veteran

    Messages:
    792
    Likes Received:
    132
    First Language:
    German
    I was working on it, so i wanted to share it.

    I just watched a Tutorial on how to show a Icon from an ItemID on the Gamescreen.

    It was a Script, but it also works as a Eventcommand Scriptcall with some little Edit.



    class Window_Custom < Window_Basedef initializesuper(0, 0, 48, 48)refreshself.opacity = 0enddef refreshdraw_icon($data_items[1].icon_index, 0, 0)endend$game_variables[1] = Window_Custom.newAnd this is for Erasing the Icon

    $game_variables[1].disposeI dont know why or how this works with a Variable, but it does :) .
     
    Last edited by a moderator: Sep 28, 2015
    #8
  9. Bex

    Bex Veteran Veteran

    Messages:
    792
    Likes Received:
    132
    First Language:
    German
    Ok i found another one, i want to share. (Hope double Post is Ok in this Case)

    Its a use Item Script Equivalent. Playm helped to build this (mostly all thanks to him).

    Usable for:

    Own Picture Menus to use Items outside the standard Menu.

    Or to differently use the Items in the Key Item List.

    The following example is used in the Eventcommand Script.

    hero = $game_party.leader #<-Useritem = $data_items[1] #<-Item_Idtargets = if !item.for_friend? [] elsif item.for_all? $game_party.members else [hero] endif hero.usable?(item) && targets.any?{ |t| t.item_test(hero, item) } hero.use_item(item) targets.each do |target| item.repeats.times{target.item_apply(hero,item)} endendThanks Playm

    Possible Users:
    $game_party.leader
    $game_actors[id]
    $game_party.members[index]

    Item_Id
    Insteed of the number for Item id you can use also [$game_variables[1]], this is needed when you want to Combine the Keyitem selection Variable with Items you can consume or use to trigger Common Events with using KeyItemList. Thatway you dont need Conditional branch for every Item used through Key Item List.

    The Database 

    Itemsettups are fully recognized.
    Target: User or whole Group
    Consumable Yes or No
    Effects on chars work and also the Call Common Event from an Event is triggered.

    Hope this comes handy for someone.
     
    Last edited by a moderator: Sep 28, 2015
    #9
  10. dii

    dii Villager Member

    Messages:
    18
    Likes Received:
    3
    First Language:
    Polish
    Ok I will try to post here my text file with collection of script calls concerning a troop and a party. When I gained a certain proficiency in RPG Maker I began to search for script calls enabling implementation of more complex ideas/skills. I see now how easy it is to find something concerning script call if you have a basic knowledge of what calls are there. Most of custom formulae thread and script call collection thread are wonderful resources but there is so much scattered around in those two threads. I hope that this txt file concerning troop and party will help someone above beginner to expand his/her knowledge concerning troop script calls :) Here I have gathered from various places calls that help to familiarize oneself with what is out there. I know it is messy but it is just a starting point :) Please remove this replay if it is not appropriate.
     

    Attached Files:

    #10

Share This Page