The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Osaka on September 11, 2010, 06:23:17 PM

Title: [SOLVED!] HUD System with ability to change common event
Post by: Osaka on September 11, 2010, 06:23:17 PM
"Advanced" HUD System
9/11/10




Summary
I've been looking around for a good HUD, but I can't seem to find what I'm looking for! Most of them display the HP/MP of a character, but what I'm looking for is a unified one that can display the date, time and stamina of the player. I've been using Jet's scripts, but I'm looking for a way to unify all of them into one HUD.

http://rmrk.net/index.php/topic,38148.msg446139.html#msg446139
http://rmrk.net/index.php/topic,38147.msg446137.html#msg446137

Secondly, I'm looking to see if there is a way a key or a button could be pressed that would turn on/off a common event with something in the HUD to say it was on/off.

Features Desired
]
[/list]

Mockups
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi5.photobucket.com%2Falbums%2Fy184%2Fhazake%2FScreenshot2.png&hash=ffeb9ba69a6d074f8f7fd046c182c02bfce6400f)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi5.photobucket.com%2Falbums%2Fy184%2Fhazake%2FScreenshot1.png&hash=23f60f2ef0361ca801a411c8ed0eca1efdb0588d)

(Ideally, I would like the HUD in that position, if possible.)

Games its been in
World's Dawn, which was made by Sagitar

http://rmrk.net/index.php/topic,39481.0.html

[/list]




Did you search?
<<Yes!>>

Where did you search?

What did you search for?

EDIT: The most important thing I'm looking for right now is just a way to quickly trigger on/off a common event using a key or some sort of button!
Title: Re: [Request] HUD System with ability to change common event
Post by: Osaka on September 12, 2010, 07:17:26 AM
I've been messing with Conditional Branch events, but for some reason nothing happens with the keys unless it's the directional buttons. Is there something I need to do in order for these keys to work?
Title: Re: [Request] HUD System with ability to change common event
Post by: The Mormegil on September 12, 2010, 09:58:12 AM
I think I can do that, if nobody else does. It seems easy to deal with, and could be a good script to test my newly-learned skills... :) I'll try to! If anybody else is willing to do this, please go ahead, I won't be angry.
Title: Re: [Request] HUD System with ability to change common event
Post by: The Mormegil on September 12, 2010, 10:54:39 AM
Well, I read the scripts an it seems that with a bit of configuration, you can have 2/3 of your requests using them alone...
Just set the windows on map to true (MAP_TIME_WINDOW = true      STAMINA_ON_MAP = true) plus set the coorinates to a proper value (a few playtests should suffice to find what these are, I would do it myself, but I haven't got RMVX on this PC).

I will do a script for the common event part.
Title: Re: [Request] HUD System with ability to change common event
Post by: Osaka on September 12, 2010, 05:30:46 PM
For some reason the Stamina Window won't show up even if I put the setting as "True" (It will show up on the menu when one presses escape.)

I went into the code and messed with it a little, and I think I have something working, but I think I will do that!

And thank you thank you thank you for writing a script  ;D
Title: Re: [Request] HUD System with ability to change common event
Post by: The Mormegil on September 13, 2010, 07:15:33 AM
I did it! :D
But the format is crappy. Anyway, I think I'll post it in the afternoon...
Title: Re: [Request] HUD System with ability to change common event
Post by: The Mormegil on September 13, 2010, 01:58:31 PM
And here we are!

#------------------------------------------------------------------
#------------------------------------------------------------------
#                  The Mormegil's Pretty Sunsets HUD
#                             v 1.0
#------------------------------------------------------------------
#------------------------------------------------------------------
#
# This is a HUD system has a window that checks if a certain Common
# Event was called, and the possibility to call it by pressing a
# button on map.
#
#------------------------------------------------------------------
#
#     $$$$$$$$$$$$$$$ CUSTOMIZATION OPTIONS $$$$$$$$$$$$$$$$$$$$
#
# You can customize the position of the window of the HUD,

TMPS_HUD_EVENT_POSITION = [0, 0]

# its text,

TMPS_HUD_TEXT_ON = "Online"
TMPS_HUD_TEXT_OFF = "Offline"

# the button you need to press to turn the common event on/off,

TMPS_BUTTON = Input::X    # default is A

# the switch this common events toggles

TMPS_SWITCH = 1           # insert ID here

# and the common event called:

TMPS_COMMON_EVENT = 1     # insert ID here

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

#                   STOP EDITING PAST THIS POINT!
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#

class Scene_Map < Scene_Base
  alias tmps_event_start start
  def start
    @window_TMPS = Window_TMPS.new(TMPS_HUD_EVENT_POSITION[0], TMPS_HUD_EVENT_POSITION[1])
    tmps_event_start
  end

  alias update_tmps update
  def update
    update_tmps
    update_tmps_event_call
    @window_TMPS.update
  end

  def update_tmps_event_call
    if Input.trigger?(TMPS_BUTTON)
      common_event = $data_common_events[TMPS_COMMON_EVENT]
      if $game_switches[TMPS_SWITCH]
        $game_switches[TMPS_SWITCH] = false
      else
        $game_switches[TMPS_SWITCH] = true
      end
      $game_temp.common_event_id = common_event.id
    end
  end
end

class Window_TMPS < Window_Base
 
  def initialize(x, y, width = 110)
    @txton = TMPS_HUD_TEXT_ON
    @txtoff = TMPS_HUD_TEXT_OFF
    super(x, y, width, WLH + 32)
    self.opacity = 255
    @width_window_tmps = self.width
    refresh
  end
 
  def refresh
    if $game_switches[TMPS_SWITCH]
      onoff = "ON"
    else
      onoff = "OFF"
    end
    self.contents.clear
    draw_event_onoff(@width_window_tmps - 8, @txton, @txtoff, onoff)
  end
 
  def draw_event_onoff(width, text_on, text_off, onoff = "OFF")
    if onoff == "ON"
      self.contents.draw_text(4, 0, width, WLH, text_on)
    elsif onoff == "OFF"
      self.contents.draw_text(4, 0, width, WLH, text_off)
    end
  end

  def update
    refresh
  end
end



I still don't know how to mess around with the format, but this should be enough to start! The rest is up to masters of RMVX language...
Title: Re: [Request] HUD System with ability to change common event
Post by: Osaka on September 13, 2010, 02:31:29 PM
This is PERFECT! Thank you so much! I'm sure this script can help a ton of people as well who are looking to have a similar effect. You are incredible.


.
Title: Re: [SOLVED!] HUD System with ability to change common event
Post by: The Mormegil on September 13, 2010, 05:06:35 PM
Well, thank you! But believe me, this was far from difficult... It was my first script after all!
Title: Re: [SOLVED!] HUD System with ability to change common event
Post by: The Mormegil on September 13, 2010, 05:38:34 PM
Actually I found a problem. It does not dispose itself. I'll work on it later, though...
Title: Re: [SOLVED!] HUD System with ability to change common event
Post by: Osaka on September 13, 2010, 06:36:21 PM
Quote from: The Mormegil on September 13, 2010, 05:38:34 PM
Actually I found a problem. It does not dispose itself. I'll work on it later, though...

I used a conditional branch within the common event, and it worked fine. So, when someone presses the A key, the common event is triggered, the conditional branch checks to see which control switch is on/off and reacts accordingly.
Title: Re: [SOLVED!] HUD System with ability to change common event
Post by: The Mormegil on September 15, 2010, 10:50:05 AM
Yeah, the problem was with the window itself. If you open, say, the menu, the window doesn't disappear. Nor does it desappear when you invoke it again (thus if you call it 300 times you'll have 300 windows on screen, one aboe the other).

Try this:
Quote#------------------------------------------------------------------
#------------------------------------------------------------------
#                  The Mormegil's Pretty Sunsets HUD
#                             v 1.0
#------------------------------------------------------------------
#------------------------------------------------------------------
#
# This is a HUD system has a window that checks if a certain Common
# Event was called, and the possibility to call it by pressing a
# button on map.
#
#------------------------------------------------------------------
#
#     $$$$$$$$$$$$$$$ CUSTOMIZATION OPTIONS $$$$$$$$$$$$$$$$$$$$
#
# You can customize the position of the window of the HUD,

TMPS_HUD_EVENT_POSITION = [0, 0]

# its text,

TMPS_HUD_TEXT_ON = "Online"
TMPS_HUD_TEXT_OFF = "Offline"

# the button you need to press to turn the common event on/off,

TMPS_BUTTON = Input::X    # default is A

# the switch this common events toggles

TMPS_SWITCH = 1           # insert ID here

# and the common event called:

TMPS_COMMON_EVENT = 1     # insert ID here

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

#                   STOP EDITING PAST THIS POINT!
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#

class Scene_Map < Scene_Base
  alias tmps_event_start start
  def start
    @window_TMPS = Window_TMPS.new(TMPS_HUD_EVENT_POSITION[0], TMPS_HUD_EVENT_POSITION[1])
    tmps_event_start
  end

  alias update_tmps update
  def update
    update_tmps
    update_tmps_event_call
    @window_TMPS.update
  end

  def update_tmps_event_call
    if Input.trigger?(TMPS_BUTTON)
      common_event = $data_common_events[TMPS_COMMON_EVENT]
      if $game_switches[TMPS_SWITCH]
        $game_switches[TMPS_SWITCH] = false
      else
        $game_switches[TMPS_SWITCH] = true
      end
      $game_temp.common_event_id = common_event.id
    end
  end
end

class Window_TMPS < Window_Base
 
  def initialize(x, y, width = 110)
    @txton = TMPS_HUD_TEXT_ON
    @txtoff = TMPS_HUD_TEXT_OFF
    super(x, y, width, WLH + 32)
    self.opacity = 255
    @width_window_tmps = self.width
    refresh
  end
 
  def refresh
    if $game_switches[TMPS_SWITCH]
      onoff = "ON"
    else
      onoff = "OFF"
    end
    self.contents.clear
    draw_event_onoff(@width_window_tmps - 8, @txton, @txtoff, onoff)
    unless $scene.is_a?(Scene_Map)
      self.dispose
    end
  end
 
  def draw_event_onoff(width, text_on, text_off, onoff = "OFF")
    if onoff == "ON"
      self.contents.draw_text(4, 0, width, WLH, text_on)
    elsif onoff == "OFF"
      self.contents.draw_text(4, 0, width, WLH, text_off)
    end
  end

  def update
    refresh
  end
end