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.

Keyboard

Question for Seph
How do you assign stuff to keys in your keyboard module

like i wanted to test it so i assigned "p" to open up Scene_Status like this

Code:
if Keyboard.pressed?(80)
    $scene = Scene_Status.new
end

and i put it at the end of the module but it didnt work so i need some help please
O_o
 

Mac

Member

I'm not familiar with this script but try doing this.

Code:
      def Keyboard.pressed?(80)
      return true if @pressed.include?(80)
       $scene = Scene_Status.new
      return false
    end
  end
 
I think you have to include the method from the script itself..
Im not that good in scripting but Necro, post the script for Mac to see..
Is that Cybersam's Keyboard Module or Near Fantastica's?
 
If you really put that inside the Keyboard Module it will never work (in fact it WILL work if you press P while Ruby Interpreter parses the code (while checking classes and methods definitions), and it happens before the game starts lol ^^). But i guess that´s not what you´re trying to do. Try to put that at Scene_Map or on any class that´s regularly updated (inside the update method, of course). Like:
Code:
class Scene_Map
  alias old_scene_map_update update
  def update
    old_scene_map_update
    if Keyboard.pressed?(80)
      $scene = Scene_status.new
    end
  end
end

... But it all depends if this Keyboard Script permits that (what i guess that happens). Maybe if you post a bit of this script we should help better... ^^
 

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