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.

Calling a script through an Event

I'm using an ABS with the game I'm working on with a friend and I'm trying to deactivate the HUD during a cinematic. I looked through the script itself and found this
Code:
 # Activate or Deactivates HUD
  # if = 0, the HUD will remain on
  OnOff_Hud_Switch = 0 -- Line 18
So I opened the event with the cinematic, and at the beggining added a Script... command like this
Code:
OnOff_Hud_Switch = 0
When I tried to run the game, the HUD didn't deactivate (nothing happened). What I want to know is, am I doing anything wrong? Is there another way to get around this? I tried replacing OnOff_Hud_Switch with a variable and then changing that variable, but when I tried to run the game, I got this error:
Code:
 Script 'HUD' line 30: SyntaxError occured.
In the script I found that Line 30 is
Code:
   if CrissaegrimHud::$game_variables[1] == 0
which previously was:   if CrissaegrimHud::OnOff_Hud_Switch == 0
So.. Am I missing something? Am I doing something wrong? Is it just a stupid mistake that I can't find?
 
Code:
#=================================
# Window Hud
# Translation to English by Nathan5555
#=================================
module CrissaegrimHud
#----------------------------------------------------------
  # Image of HUD
  Picture_Base = "HUD-Base"

  # Image of Skills HUD
  Picture_Hot_Skills = "HUD-Skills"
  
  # Image of Items HUD
  Picture_Hot_Items = "HUD-Items"
  
  # Activate or Deactivates HUD
  # if = 0, the HUD will remain on
  OnOff_Hud_Switch = 0
#----------------------------------------------------------
end
#----------------------------------------------------------
class Window_CrissaegrimHud < Window_Base
  def initialize
    super(-12,-12,190,117)
    self.opacity = 0
    self.visible = false
    update
  end
   def update
     if CrissaegrimHud::OnOff_Hud_Switch == 0
       self.visible = true
       self.active = true
     else
     if $game_switches[CrissaegrimHud::OnOff_Hud_Switch] == true
       self.visible = true
       self.active = true
     else
       self.visible = false
       self.active = false
     end
   end
     self.contents.clear
      bitmap = Cache.system(CrissaegrimHud::Picture_Base)
      self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 148, 85))
     refresh
   end
   def refresh
      actor = $game_actors[1]
      draw_actor_hp(actor, 16, 0, 96)
      draw_actor_mp(actor, 16, 24, 96)
      draw_actor_level(actor, 16, 48)
      show_state(actor, 119, 2)
    end
    def show_state(actor, x, y, width = 32)
    count = 0
    for state in actor.states
      draw_icon(state.icon_index, x, y + 28 * count)
      count += 1
      break if (24 * count > height - 24)
    end
  end
end
#----------------------------------------------------------
class Window_CrissaegrimHud2 < Window_Base
  def initialize
    super(40,347,296,80)
    self.opacity = 0
    self.visible = false
    update
  end
   def update
     if CrissaegrimHud::OnOff_Hud_Switch == 0
       self.visible = true
       self.active = true
     else
     if $game_switches[CrissaegrimHud::OnOff_Hud_Switch] == true
       self.visible = true
       self.active = true
     else
       self.visible = false
       self.active = false
     end
   end
     self.contents.clear
      bitmap = Cache.system(CrissaegrimHud::Picture_Hot_Skills)
      self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 156, 48))
      skill_count = 0
      for button in Crissaegrim_ABS::Skill_Button.keys
        next if button == nil
        skill = $data_skills[Crissaegrim_ABS::Skill_Button[button]]
        next if skill == nil
        show_icon(skill, 10 + 28 * skill_count, 8)
        self.contents.font.size = 16
#          self.contents.draw_text(16 + 28 * skill_count, 26, 32, 18, "")
        skill_count += 1
      end
    end
    def show_icon(item, x, y, enabled = true)
    if item != nil
      draw_icon(item.icon_index, x, y, enabled)
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
    end
  end
end
#----------------------------------------------------------
class Window_CrissaegrimHud3 < Window_Base
  def initialize
    super(-12,225,80,202)
    self.opacity = 0
    self.visible = false
    update
  end
   def update
     if CrissaegrimHud::OnOff_Hud_Switch == 0
       self.visible = true
       self.active = true
     else
     if $game_switches[CrissaegrimHud::OnOff_Hud_Switch] == true
       self.visible = true
       self.active = true
     else
       self.visible = false
       self.active = false
     end
   end
     self.contents.clear
      bitmap = Cache.system(CrissaegrimHud::Picture_Hot_Items)
      self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 48, 170))
      item_count = 0
      for button in Crissaegrim_ABS::Item_Button.keys
        next if button == nil
        item = $data_items[Crissaegrim_ABS::Item_Button[button]]
        next if item == nil
        show_item_icon(item, 4, 8 + 30 * item_count)
        self.contents.font.size = 16
        self.contents.draw_text(28, 12 + 30 * item_count, 32, 18, $game_party.item_number(item))
        item_count += 1
      end
    end
    def show_item_icon(item, x, y, enabled = true)
    if item != nil
      draw_icon(item.icon_index, x, y, enabled)
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
    end
  end
 end
#----------------------------------------------------------
class Scene_Map
  alias hud_start start
  alias hud_update update
  alias hud_terminate terminate
  def start
    super
    @hud = Window_CrissaegrimHud.new
    @hud2 = Window_CrissaegrimHud2.new
    @hud3 = Window_CrissaegrimHud3.new
    hud_start
  end
  def update
    super
    @hud.update
    @hud2.update
    @hud3.update
    hud_update
  end
  def terminate
    super
    @hud.dispose
    @hud2.dispose
    @hud3.dispose
    hud_terminate
  end
end
This is the script that interests me, it's the HUD from an ABS (Crissaegrim ABS, made by Vlad and translated by Nathan5555), and it's the only script where OnOff_Hud_Switch is mentioned.
 

kire

Member

Hi if you want to deactivate the HUD deactivate the switch that is said in the script( Im using that at the moment too) 0 = No switch will remain always on
1 = switch 1 Activate the switch to activate the Hud and deactivate the switch to deactivate the hud, that goes to 2,3,4,5,6,7,8,9,etc.
If you want the Hud in the begining make an event that says:
-Switch X: on
And when you want to deactivate make an event that says:
-Switch X: off

X = 1,2,3,4,5,6,7,8,9,etc.
 

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