Hunger/variable changing script and on-screen HUD.

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

First, the script part:



  1. class Window_hunger < Window_Base
  2.   def initialize
  3.     super(100, 400, 100, 80)
  4.       self.back_opacity = 145
  5.     self.contents = Bitmap.new(200 - 32, 80 - 32)
  6.     refresh
  7.   end
  8.   def refresh
  9.     self.contents.clear
  10.     @hunger = $game_variables[1]
  11.     self.contents.draw_text(0, 0, 190, 70, $game_variables[1].to_s)
  12.         self.contents.draw_text(0, -15, 190, 70, 'Hunger'.to_s)
  13.   end
  14.   def update
  15.     super
  16.     if $game_variables[1] != @hunger
  17.        refresh
  18.     end
  19.   end
  20. end
  21.  
  22. #HUD2 UPDATE
  23. class Scene_Map
  24.   alias hunger_main main
  25.   alias hunger_update update
  26.   def main
  27.     @hunger = Window_hunger.new
  28.     hunger_main
  29.     @hunger.dispose
  30.   end
  31.   def update
  32.     @hunger.update
  33.     hunger_update
  34.   end
  35. end
Expand to see the code.




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).
I've gotta say, this rocks! Great stuff, I really needed a hunger script :)
Thanks, man 😀
Wouldn't you make some hunger script that doesn't require to configure events to make it work?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=67841