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.

Hunger/variable changing script and on-screen HUD.

My first WORKING script
This script is free to use and such.

First, the script part:



Code:
class Window_hunger < Window_Base 

  def initialize 

    super(100, 400, 100, 80) 

      self.back_opacity = 145 

    self.contents = Bitmap.new(200 - 32, 80 - 32) 

    refresh 

  end 

  def refresh 

    self.contents.clear 

    @hunger = $game_variables[1] 

    self.contents.draw_text(0, 0, 190, 70, $game_variables[1].to_s) 

        self.contents.draw_text(0, -15, 190, 70, 'Hunger'.to_s) 

  end 

  def update 

    super 

    if $game_variables[1] != @hunger 

       refresh 

    end 

  end 

end 

  

#HUD2 UPDATE 

class Scene_Map 

  alias hunger_main main 

  alias hunger_update update 

  def main 

    @hunger = Window_hunger.new 

    hunger_main 

    @hunger.dispose 

  end 

  def update 

    @hunger.update 

    hunger_update 

  end 

end



And now the EVENT part.
Just put the event on any map that you want hunger enabled.

wait: 60 frames
control variables - 1

conditional branch:
variable hunger >= 101
control variable hunger = 100
else


conditional branch:
variable hunger <= 0
control variables hunger = 0
decrease hp = 30

else

branch end



You can also edit this script to be used for sleep and other motives used in survival/Sim games (which i am currently working on).
 

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