P's Priority Checking [Exclusive]
#1
P's Priority Check
Version: 1

Introduction
This script adds a feature that was lacking in the default scripts: Getting the priority value of a tile.
There's also a few niceties added just to make the script stand out a little from any possible priority-checking scripts.

Features
  • Check the priority value of a non-blank tile in the top-most layer with script call: $game_map.priority?(x, y) or $game_map.priority(x, y, -1)
  • Check the priority value of a tile in a specific layer with script call: $game_map.priority?(x, y, layer).
  • For those who tend to want their results "printed" (alert box!), the script would print the returning value of with this script call: $game_map.priority?(x, y, layer, true)
Screenshots
[Image: eulm5l.png]

Script
Code:
=begin
????????????????????????????????????????????????????????????????????????????????
? PK8's Priority Check                                                         ?
? Version 1                                                                    ?
? by PK8                                                                       ?
????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
? ? Description:                                                               ?
? ?? This script adds a feature that was lacking in the default script:        ?
?    Getting the priority value of a tile.                                     ?
?    There's also a few niceties added just to make the script stand out a     ?
?    little from any possible priority-checking scripts.                       ?
????????????????????????????????????????????????????????????????????????????????
? ? Features:                                                                  ?
? ?? Check the priority value of a non-blank tile in the top-most layer with   ?
? ?  script call: $game_map.priority?(x, y) or $game_map.priority(x, y, -1)    ?
? ?? Check the priority value of a tile in a specific layer with script call:  ?
? ?  $game_map.priority?(x, y, layer).                                         ?
? ?? For those who tend to want their results "printed" (alert box!), the      ?
?    script would print the returning value of with this script call:          ?
?    $game_map.priority?(x, y, layer, true)                                    ?
????????????????????????????????????????????????????????????????????????????????
? ? Usage and examples:                                                        ?
? ?? The script call: $game_map.priority?(x, y, layer, print)                  ?
?                                                                              ?
?  x: X-coordinate of a map.                                                   ?
?  y: Y-coordinate of a map.                                                   ?
?  layer: Map layer. (-1:All layers(default), 0:1st, 1:2nd, 2:3rd) (Optional)  ?
?  print: Prints value from the call. (false:no(default), true:Yes) (Optional) ?
????????????????????????????????????????????????????????????????????????????????
? ? Tips:                                                                      ?
? ?? Get the priority value of the tile in top-most layer where your player is ?
?    standing by calling this:                                                 ?
?    $game_map.priority?($game_player.x, $game_player.y)                       ?
?                                                                              ?
? You ought to try mixing that with if conditions. You might be able to do some?
? nice stuff. :P                                                               ?
????????????????????????????????????????????????????????????????????????????????
=end

class Game_Map
  def priority?(x, y, i = -1, print = false)
    if @map_id != 0
      # If layer isn't specified or user deliberately types in -1 in the call.
      if i == -1
        # Checking all layers.
        for i in [2, 1, 0]
          tile_id = data[x, y, i]
          # Returns 0 if the top-most tiles are blank or something.
          if tile_id == 0
            if i != 0
              next
            end
            # Prints the returning value if fourth argument is true.
            if print == true
              print 0
            end
            return 0
          # Returns top-most tile's priority if there.
          elsif tile_id >= 1
            # Prints the returning value if fourth argument is true.
            if print == true
              print priorities[tile_id]
            end
            return priorities[tile_id]
          end
        end
      end
      # If developer types in a specific layer in the call.
      if i != -1
        tile_id = data[x, y, i]
        if tile_id == 0
          # Prints the returning value if fourth argument is true.
          if print == true
            print 0
          end
          return 0
        # Returns layer-specific tile's priority if there.
        elsif tile_id >= 1
          # Prints the returning value if fourth argument is true.
          if print == true
            print priorities[tile_id]
          end
          return priorities[tile_id]
        end
      end
      return 0
    end
  end
end

Instructions
Simply copy-paste the script into your project. Examples of use are included in the script.

FAQ
No questions asked so far.

Compatibility
Dunno.

Credits and Thanks
No thanks. ;P

Author's Notes
Feel free to let me know if there's any bugs so I could try to fix it.

Terms and Conditions
Just credit me, it's all I ask. :3
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Alisha's Removables (Exclusive) DerVVulfman 2 6,513 04-09-2013, 03:39 AM
Last Post: DerVVulfman
   P's Pause Script v2.0.1 (Updated: July 5th, 2009) [Exclusive] PK8 13 24,039 09-16-2009, 09:34 PM
Last Post: PK8
   MapSwitch 2 for RPG Maker XP [Exclusive] PK8 0 4,801 07-03-2009, 03:33 PM
Last Post: PK8
   Game Over Replacer + Enhancer [Exclusive] PK8 0 8,024 07-03-2009, 10:31 AM
Last Post: PK8



Users browsing this thread: 1 Guest(s)