Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Two Simple Scripts :D

Ok, before all of you start insulting me and telling me to learn proper english, i have to say that i speak spanish, just a little bit of english xD... So forgive my poor english and make an effort to understand xD...

Now, before the scripts, i guess i have to tell you why i need these scripts right?.. Well, i'm making a Silent Hill Project (http://wickedrekiem.webs.com/) (Is in Spanish tough...) (And Thanks to Cor Leonis if you're watching this, your sprites really helped a lot :D)... I proceed xD, the project is going very nice, but there are some little problems, of course, these scripts are not necessary, but you will help me a lot, if you can do that little favor for me =)...

Before specifying the scripts, a introduction of both, The first one is a simple (or at least it looks simple xD) Scene_Item, why Scene_Item?... A simple engine, when player press "I" Button the inventory (Scene_Item) opens... Well that is not the script xD... When the "Inventory" opens it's the default Scene_Item D: ... The second script can be tricky, i think... Let's go to it, have you played Silent Hill?.. Remember the Radio?.. Well, i want a script like that, but see below for more info :D

Script Title:
Simple Inventory
RMXP or RMVX: XP
Detailed Description:
Ok, I need the inventory not to cover all the screen, but just a little part at a side of the character (Look the image to understand), i don't want to give you so much work, so only windowskin, no complex image or bitmaps, i need items to be agrouped depending on their type (Objects, Weapons, and Files) (Again, look the image for better explanation... The Type of the items may be applied with attributes, i think, example, weapons have "X" Attributte... items have "Z" Attributte... where "X" and "Z" are numbers... navigation in the menu is simple, Up/Down: Browse Items, Left/right: Browse Category...

Optional:

Two windows at a side of the menu, one containing a picture of the highlighted item, the other containing description.. i know i didn't explained it very well, but the image is self explanatory :3

Screen shots:
Dibujo.PNG


Now the second script...

Script Title:
Silent Hill's Like Radio
RMXP or RMVX: XP
Detailed Description: Ok, i try to explain it well... If "X" Event have "X" Commentary (The Commentary can be "Monste"r or something) then is processed like a monster, and, if "X" Switch is active then the script start... The script should play a SE... the volume of the SE Depends of the distance between the Character and the "Monsters" (The Events with the "monster" commentary), and when all of the monsters in a map are eliminated then the SE stops...

Ok.. that is all... I know that MANY people wont understand too mucho because of this shitty english xD.. The second script is very bad explained but well... Thanks for reading :lol:
 
here is the code to fix your easy problem
Code:
CALL_KEY = Input::Letters["I"]

class Scene_Map

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------  

  alias_method :plague180_scene_map_update,          :update

  #-----------------------------------------------------------------------------

  # * update

  #-----------------------------------------------------------------------------

  def update

    plague180_scene_map_update

    if Input.pressed?(CALL_KEY)     

      $scene = Scene_Item.new

    end 

  end  

end
this code uses Cybersam's keyboard input script, i couldnt find the link, but here is the code for that. put the keyboard script above my edit of scene map.
Code:
#==============================================================================

# Keyboard Input Module

#----------------------------------------------------------------------------

# Script by Cybersam

#==============================================================================

 

module Input

  @keys = []

  @pressed = []

  Mouse_Left = 1

  Mouse_Right = 2

  Mouse_Middle = 4

  Back= 8

  Tab = 9

  Enter = 13

  Shift = 16

  Ctrl = 17

  Alt = 18

  Esc = 27

  Space = 32

  Numberkeys = {}

  Numberkeys[0] = 48        # => 0

  Numberkeys[1] = 49        # => 1

  Numberkeys[2] = 50        # => 2

  Numberkeys[3] = 51        # => 3

  Numberkeys[4] = 52        # => 4

  Numberkeys[5] = 53        # => 5

  Numberkeys[6] = 54        # => 6

  Numberkeys[7] = 55        # => 7

  Numberkeys[8] = 56        # => 8

  Numberkeys[9] = 57        # => 9

  Numberpad = {}

  Numberpad[0] = 45

  Numberpad[1] = 35

  Numberpad[2] = 40

  Numberpad[3] = 34

  Numberpad[4] = 37

  Numberpad[5] = 12

  Numberpad[6] = 39

  Numberpad[7] = 36

  Numberpad[8] = 38

  Numberpad[9] = 33

  Letters = {}

  Letters["A"] = 65

  Letters["B"] = 66

  Letters["C"] = 67

  Letters["D"] = 68

  Letters["E"] = 69

  Letters["F"] = 70

  Letters["G"] = 71

  Letters["H"] = 72

  Letters["I"] = 73

  Letters["J"] = 74

  Letters["K"] = 75

  Letters["L"] = 76

  Letters["M"] = 77

  Letters["N"] = 78

  Letters["O"] = 79

  Letters["P"] = 80

  Letters["Q"] = 81

  Letters["R"] = 82

  Letters["S"] = 83

  Letters["T"] = 84

  Letters["U"] = 85

  Letters["V"] = 86

  Letters["W"] = 87

  Letters["X"] = 88

  Letters["Y"] = 89

  Letters["Z"] = 90

  Fkeys = {}

  Fkeys[1] = 112

  Fkeys[2] = 113

  Fkeys[3] = 114

  Fkeys[4] = 115

  Fkeys[5] = 116

  Fkeys[6] = 117

  Fkeys[7] = 118

  Fkeys[8] = 119

  Fkeys[9] = 120

  Fkeys[10] = 121

  Fkeys[11] = 122

  Fkeys[12] = 123

  Collon = 186        # => \ |

  Equal = 187         # => = +

  Comma = 188         # => , <

  Underscore = 189    # => - _

  Dot = 190           # => . >

  Backslash = 191     # => / ?

  Lb = 219

  Rb = 221

  Quote = 222         # => '"

  #-------------------------------------------------------------------------------

  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle] 

  #-------------------------------------------------------------------------------

  

module_function

  #--------------------------------------------------------------------------

  def triggered?(key)

    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1

  end

  #-------------------------------------------------------------------------- 

  def check(key)

    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1

  end

  #--------------------------------------------------------------------------

  def pressed?(key)

    return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)

    return false

  end

  #--------------------------------------------------------------------------

  def mouse_update

    @used_i = []

    for i in USED_KEYS

      x = check(i)

      if x == true

        @used_i.push(i)

      end

    end

  end

  #--------------------------------------------------------------------------

  def self.C

    self.trigger?(C)

  end

  #-------------------------------------------------------------------------- 

  def self.B

    self.trigger?(B)

  end

  #-------------------------------------------------------------------------- 

  def self.A

    self.trigger?(A)

  end

  #-------------------------------------------------------------------------- 

  def self.Down

    self.trigger?(DOWN)

  end

  #-------------------------------------------------------------------------- 

  def self.Up

    self.trigger?(UP)

  end

  #-------------------------------------------------------------------------- 

  def self.Right

    self.trigger?(RIGHT)

  end

  #-------------------------------------------------------------------------- 

  def self.Left

    self.trigger?(LEFT)

  end

  #--------------------------------------------------------------------------

  def self.Anykey

    if A or B or C or Down or Up or Right or Left

      return true

    else

      return false

    end

  end

  #--------------------------------------------------------------------------

end

 
if someone doesnt do the other part i will try to help while i wait for some help on my other project
 
Plague180":2zm84obp said:
here is the code to fix your easy problem
Code:
CALL_KEY = Input::Letters["I"]

class Scene_Map

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------  

  alias_method :plague180_scene_map_update,          :update

  #-----------------------------------------------------------------------------

  # * update

  #-----------------------------------------------------------------------------

  def update

    plague180_scene_map_update

    if Input.pressed?(CALL_KEY)     

      $scene = Scene_Item.new

    end 

  end  

end
this code uses Cybersam's keyboard input script, i couldnt find the link, but here is the code for that. put the keyboard script above my edit of scene map.
Code:
#==============================================================================

# Keyboard Input Module

#----------------------------------------------------------------------------

# Script by Cybersam

#==============================================================================

 

module Input

  @keys = []

  @pressed = []

  Mouse_Left = 1

  Mouse_Right = 2

  Mouse_Middle = 4

  Back= 8

  Tab = 9

  Enter = 13

  Shift = 16

  Ctrl = 17

  Alt = 18

  Esc = 27

  Space = 32

  Numberkeys = {}

  Numberkeys[0] = 48        # => 0

  Numberkeys[1] = 49        # => 1

  Numberkeys[2] = 50        # => 2

  Numberkeys[3] = 51        # => 3

  Numberkeys[4] = 52        # => 4

  Numberkeys[5] = 53        # => 5

  Numberkeys[6] = 54        # => 6

  Numberkeys[7] = 55        # => 7

  Numberkeys[8] = 56        # => 8

  Numberkeys[9] = 57        # => 9

  Numberpad = {}

  Numberpad[0] = 45

  Numberpad[1] = 35

  Numberpad[2] = 40

  Numberpad[3] = 34

  Numberpad[4] = 37

  Numberpad[5] = 12

  Numberpad[6] = 39

  Numberpad[7] = 36

  Numberpad[8] = 38

  Numberpad[9] = 33

  Letters = {}

  Letters["A"] = 65

  Letters["B"] = 66

  Letters["C"] = 67

  Letters["D"] = 68

  Letters["E"] = 69

  Letters["F"] = 70

  Letters["G"] = 71

  Letters["H"] = 72

  Letters["I"] = 73

  Letters["J"] = 74

  Letters["K"] = 75

  Letters["L"] = 76

  Letters["M"] = 77

  Letters["N"] = 78

  Letters["O"] = 79

  Letters["P"] = 80

  Letters["Q"] = 81

  Letters["R"] = 82

  Letters["S"] = 83

  Letters["T"] = 84

  Letters["U"] = 85

  Letters["V"] = 86

  Letters["W"] = 87

  Letters["X"] = 88

  Letters["Y"] = 89

  Letters["Z"] = 90

  Fkeys = {}

  Fkeys[1] = 112

  Fkeys[2] = 113

  Fkeys[3] = 114

  Fkeys[4] = 115

  Fkeys[5] = 116

  Fkeys[6] = 117

  Fkeys[7] = 118

  Fkeys[8] = 119

  Fkeys[9] = 120

  Fkeys[10] = 121

  Fkeys[11] = 122

  Fkeys[12] = 123

  Collon = 186        # => \ |

  Equal = 187         # => = +

  Comma = 188         # => , <

  Underscore = 189    # => - _

  Dot = 190           # => . >

  Backslash = 191     # => / ?

  Lb = 219

  Rb = 221

  Quote = 222         # => '"

  #-------------------------------------------------------------------------------

  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle] 

  #-------------------------------------------------------------------------------

  

module_function

  #--------------------------------------------------------------------------

  def triggered?(key)

    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1

  end

  #-------------------------------------------------------------------------- 

  def check(key)

    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1

  end

  #--------------------------------------------------------------------------

  def pressed?(key)

    return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)

    return false

  end

  #--------------------------------------------------------------------------

  def mouse_update

    @used_i = []

    for i in USED_KEYS

      x = check(i)

      if x == true

        @used_i.push(i)

      end

    end

  end

  #--------------------------------------------------------------------------

  def self.C

    self.trigger?(C)

  end

  #-------------------------------------------------------------------------- 

  def self.B

    self.trigger?(B)

  end

  #-------------------------------------------------------------------------- 

  def self.A

    self.trigger?(A)

  end

  #-------------------------------------------------------------------------- 

  def self.Down

    self.trigger?(DOWN)

  end

  #-------------------------------------------------------------------------- 

  def self.Up

    self.trigger?(UP)

  end

  #-------------------------------------------------------------------------- 

  def self.Right

    self.trigger?(RIGHT)

  end

  #-------------------------------------------------------------------------- 

  def self.Left

    self.trigger?(LEFT)

  end

  #--------------------------------------------------------------------------

  def self.Anykey

    if A or B or C or Down or Up or Right or Left

      return true

    else

      return false

    end

  end

  #--------------------------------------------------------------------------

end

 
if someone doesnt do the other part i will try to help while i wait for some help on my other project

Ehh... Thanks... But.. That wasn't the problem n.n... I'd already know how to open the menu with the "I" button... i just want the scripts for the inventory design n.n..
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top