I've been messing around with something that seems like it should be stoopidly simple for hours now and can't quite figure it out. Right now, I'm working on a Rune Factory-ish game and am using Galv's "Use Item on Event" script to create a gift-giving system.
However, I'm also using a HUD. Whenever I open up the "use item" box from Galv's script, it pops over my HUD and looks really dum. ;9
[Spoiler=Super dum]
Normal:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2F73R4RaM.png%3F1&hash=adcef8512873e0d374a06faf20a92130f1ae8e6e)
When I pull up the script's item box:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FWge443H.png%3F1&hash=2b73951aba29f8da69eb0edf58b76a12f1960a97)
... ;9
[/Spoiler]
So, basically I just spent the last couple of hours trying to squeeze in a common event that I have assembled to quickly turn the HUD on and off (only uses one common event - ID: 1). I've tried to place "$game_temp.reserve_common_event(1)" all around the script to try to call the common event twice - once to turn off the HUD when the item screen pops up, and the second time to bring the HUD back when the item screen goes away. I've managed to get it to trigger when the item screen drops, but not when it starts.
I'm sure there are ways that I can do this without editing the script, but I'm trying to be conservative about lag this time around, so I'd like to avoid running a parallel process.
If someone can help me out with this, I will be forever indebted to you, your ancestors, and your kin. :gracie:
[Spoiler=Galv's script]
#------------------------------------------------------------------------------#
# Galv's Use Item on Event
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.5
#------------------------------------------------------------------------------#
# 2013-01-10 - version 1.5 - added a hopeful fix for strange issue
# 2012-12-13 - version 1.4 - added ability to set what happens when item is
# used on nothing (or an event with no <key> tag).
# - added a check for just category
# 2012-12-07 - version 1.3 - bug where sometimes item doesn't register
# 2012-12-07 - version 1.2 - fix indexing bug when changing categories
# 2012-12-07 - version 1.1 - fixed bug when only using 1 category
# 2012-12-07 - version 1.0 - release
#------------------------------------------------------------------------------#
# This script allows you to bring up the "Use Key Item" box on the press of a
# button. When you select an item, it then activates the event directly in
# front of the player.
# Using EVENTING knowledge, you can set up conditional branches that contain
# 'script' condition to tell the event what to do when the item the player
# selected was used on that event.
#------------------------------------------------------------------------------#
# SCRIPTS for CONDITIONAL BRANCHES
#------------------------------------------------------------------------------#
#
# use_key? # Returns true if you activated the event using an item.
#
# key?(:category,item_id) # Checks if that item was used.
# # :category can be any from CATEGORIES below.
# # item_id is the ID of the item from that category
#
# keyc?(:category) # Check if any item from that category was used
#
#------------------------------------------------------------------------------#
# SCRIPT call for ENDING an item-initiated event (IMPORTANT)
#------------------------------------------------------------------------------#
#
# end_key # Use this instead of "Exit Event Processing" event command in
# # your item activated events to clear the item ID if you want
# # to end the event early like in the demo examples.
#
#------------------------------------------------------------------------------#
# COMMENT TAG FOR EVENTS
#------------------------------------------------------------------------------#
#
# <key>
#
# Place a COMMENT in the event page with only this tag in it. Make sure the
# comment is BELOW all conditional branches checking for item used on the event
#
# Any event that has this comment will be activated when using an item on it
# (just like if you used the action key). Any event without this tag will not
# be activated at all and will revert to the common event id (selected below).
#
#------------------------------------------------------------------------------#
($imported ||= {})["Galvs_Use_Item_on_Event"] = true
module Galv_Key
#------------------------------------------------------------------------------#
# SCRIPT SETTINGS
#------------------------------------------------------------------------------#
DISABLE_SWITCH = 4
BUTTON = :X # Button to call Key Item window (:X is "a")
VARIABLE = 5 # Stores item ID in this variable to use in conditions
NO_TARGET = 0 # Common event ID. This is called when the player uses an
# item on nothing and can be used to set what happens for
# each item/category in this event.
# IMPORTANT: Set to 0 if not used. Common event MUST have
# the key_end script call at the end of the event and end
# of any branch as normal.
CATEGORIES = [ # Categories of items that can be used on an
# event. Cycle through these categories with
[:key_item, "Key Items"], # Q and W. Remove any you do not want to use
[:item, "Items"], # in your game.
[:weapon, "Weapons"],
[:armor, "Armor"],
] # don't touch
CHANGE_CAT_LEFT = "S < " # Text before the heading
LEFT_BUTTON = :Y # Button to swap category to the left
CHANGE_CAT_RIGHT = " > D" # Text after the heading
RIGHT_BUTTON = :Z # Button to swap category to the right
#------------------------------------------------------------------------------#
# END SCRIPT SETTINGS
#------------------------------------------------------------------------------#
end
class Game_Interpreter
alias galv_key_item_interpreter_execute_command execute_command
def execute_command
if !@list[@index].nil?
if @list[@index].code == 108
$game_variables[Galv_Key::VARIABLE] = 0 if @list[@index].parameters[0] == "<key>"
end
end
galv_key_item_interpreter_execute_command
end
def end_key
@index = @list.size
$game_variables[Galv_Key::VARIABLE] = 0
end
def use_key?
$game_variables[Galv_Key::VARIABLE] > 0
end
def key?(cat,item_id)
if cat == $game_system.key_item_cat && $game_variables[Galv_Key::VARIABLE] == item_id
return true
else
return false
end
end
def keyc?(cat)
if cat == $game_system.key_item_cat && $game_variables[Galv_Key::VARIABLE] > 0
return true
else
return false
end
end
end # Game_Interpreter
class Game_Player < Game_Character
alias galv_key_item_move_by_input move_by_input
def move_by_input
galv_key_item_move_by_input
if Input.trigger?(Galv_Key::BUTTON)
return if $game_switches[Galv_Key::DISABLE_SWITCH] || jumping?
$game_message.item_choice_variable_id = Galv_Key::VARIABLE if !$game_map.interpreter.running?
end
end
def use_on_event
case @direction
when 2; dirx = 0; diry = 1
when 4; dirx = -1; diry = 0
when 6; dirx = 1; diry = 0
when 8; dirx = 0; diry = -1
end
@enable_event = false
for event in $game_map.events_xy(@x+dirx, @y+diry)
event.list.count.times { |i|
if event.list[i].code == 108 && event.list[i].parameters[0] == "<key>"
@enable_event = true
end
}
end
if @enable_event
event.start
else
if Galv_Key::NO_TARGET > 0
$game_temp.reserve_common_event(Galv_Key::NO_TARGET)
else
$game_variables[Galv_Key::VARIABLE] = 0
end
end
end
end # Game_Player < Game_Character
class Window_KeyItem < Window_ItemList
alias galv_key_item_key_window_on_ok on_ok
def on_ok
galv_key_item_key_window_on_ok
$game_player.use_on_event
clear_heading
end
alias galv_key_item_key_window_on_cancel on_cancel
def on_cancel
galv_key_item_key_window_on_cancel
clear_heading
end
alias galv_key_item_key_window_start start
def start
if !$game_switches[Galv_Key::DISABLE_SWITCH]
self.category = $game_system.key_item_cat
draw_heading
update_placement
refresh
select(0)
open
activate
else
galv_key_item_key_window_start
end
end
def draw_heading
return if @heading != nil
@heading = Sprite.new
@heading.bitmap = Bitmap.new(Graphics.width, 25)
@heading.bitmap.font.size = 25
@heading.bitmap.font.color.set(text_color(0))
@position = 0 if @position.nil?
if Galv_Key::CATEGORIES.count > 1
text = Galv_Key::CHANGE_CAT_LEFT + Galv_Key::CATEGORIES[@position][1] + Galv_Key::CHANGE_CAT_RIGHT
else
text = Galv_Key::CATEGORIES[@position][1]
end
@heading.bitmap.draw_text(@heading.bitmap.rect, text, 1)
if @message_window.y >= Graphics.height / 2
@heading.y = @message_window.height
else
@heading.y = Graphics.height - height + @message_window.height
end
@heading.z = z + 1
@heading.opacity = 0
end
def clear_heading
@heading.dispose
@heading.bitmap.dispose
@heading = nil
end
def enable?(item)
if !$game_switches[Galv_Key::DISABLE_SWITCH]
true
else
super
end
end
def update
super
@heading.opacity = openness if !@heading.nil?
if self.active && Galv_Key::CATEGORIES.count > 1
if Input.trigger?(Galv_Key::LEFT_BUTTON)
Galv_Key::CATEGORIES.each_with_index do |c,i|
@position = i if c[0] == $game_system.key_item_cat
end
@position -= 1
@position = Galv_Key::CATEGORIES.count - 1 if @position < 0
self.category = $game_system.key_item_cat = Galv_Key::CATEGORIES[@position][0]
clear_heading
draw_heading
select(0)
end
if Input.trigger?(Galv_Key::RIGHT_BUTTON)
Galv_Key::CATEGORIES.each_with_index do |c,i|
@position = i if c[0] == $game_system.key_item_cat
end
@position += 1
@position = 0 if @position >= Galv_Key::CATEGORIES.count
self.category = $game_system.key_item_cat = Galv_Key::CATEGORIES[@position][0]
clear_heading
draw_heading
select(0)
end
end
end
end # Window_KeyItem < Window_ItemList
class Game_System
attr_accessor :key_item_cat
alias galv_key_item_system_initialize initialize
def initialize
galv_key_item_system_initialize
@key_item_cat = Galv_Key::CATEGORIES[0][0]
end
end
[/Spoiler]
i also dont kno how 2 scropt :O
my idea is just to move the window, if you dnt like that idea i understand
if moving the window is okay than place this ubove the gift script
class Window_KeyItem < Window_ItemList
def update_placement
if @message_window.y >= Graphics.height / 2
self.y = 144
else
self.y = Graphics.height - height
end
end
end
I can try to toggle the hud if you give me the script for the hud (can be in PM). If the HUD is evented, then give me the switch for it :B
Awww, thanks for the quick replies, guys! ;-;
Quote from: Lord Stark on July 26, 2014, 07:43:37 AM
i also dont kno how 2 scropt :O
my idea is just to move the window, if you dnt like that idea i understand
if moving the window is okay than place this ubove the gift script
[Spoiler]class Window_KeyItem < Window_ItemList
def update_placement
if @message_window.y >= Graphics.height / 2
self.y = 144
else
self.y = Graphics.height - height
end
end
end
[/Spoiler]
I considered moving the window, but wasn't sure how it would look (nor did I know how to move it ;_; ). Now that I've tested out your snippet, I think that looks pretty good, too! B)
Quote from: Chaos_Zexion on July 26, 2014, 07:59:51 AM
I can try to toggle the hud if you give me the script for the hud (can be in PM). If the HUD is evented, then give me the switch for it :B
The HUD is part scripted and part evented. :B
[Spoiler=picture]
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FqemG9BJ.png%3F1&hash=73b98989969c973594266dfb044eb3130585f03e)
[/Spoiler]
Basically, I spawn the event in game and it checks if the HUD switch is on or off and makes the opposite happen. The HUD switch itself turns the HUD face and hp/st bars off, the pictures are for the clock and HUD background, and the script call is to clear the clock's contents.
I may have done some minor edits to the script, so here's my version of it:
[Spoiler=the HUD script, just in case!]
#===== Rpg Makver VX ACE Script =============================
#= Simple Hud
#===== By: ==================================================
#= lilcooldude69
#===== Current Version: =====================================
#= 1.0
#===== Compatible With: =====================================
#= Rpg Maker VX ACE
#===== Description: =========================================
#= Sells items useful for 2-2 Classes
#===== Additional Comments: =================================
#=
#============================================================
module Hud_config
#Configuration
SWITCH = 1 #the number of the switched used to make it visible Example: if this is 1 then Switch 001 will turn on the hud.
#EXPTERM = "Exp" #Term used for The Exp Bar
#GOLD = "G" #Term used for the Gold, You may have to make adjustments below if > 1 character
OPACITY = 200 #used for the opacity of the window, Mess with this to your liking :P
SHOW_EQUIP = 0 # The equipment piece shown. This is the slot ID.
# 0 = weapon
# 1 = shield
# 2 = head
# 3 = body
# 4 = accessory
#end config
end
#=====DO NOT EDIT PAST HERE UNLESS YOU KNOW WHAT YOUR DOING======#
#=================EXCLUDING WHAT WAS SAID ABOVE==================#
include Hud_config
class Window_Hud < Window_Base
#----------------------------------------------------
# * Object Initialization
#----------------------------------------------------
def initialize
super(0,3,255,70)
self.windowskin = Cache.system("Window_HUD")
self.back_opacity = 255
create_contents
self.visible = $game_switches[SWITCH]
@actor = $game_party.members[0]
refresh
end
def exp_gauge_color1; text_color(31); end;
def exp_gauge_color2; text_color(27); end;
#----------------------------------------------------
# * Refresh
#----------------------------------------------------
def refresh
self.contents.clear
contents.clear
draw_window_content
end
#----------------------------------------------------
# * Draw Window Contents * Drawing of all the contents gold, hp bar, etc
#----------------------------------------------------
def draw_window_content
@gold = $game_party.gold
@level = @actor.level
@hp = @actor.hp
@mp = @actor.mp
@tp = @actor.tp
@exp = @actor.exp
draw_face(@actor.face_name, @actor.face_index, 5, -20, enable = false)
contents.font.size = 20
#draw_actor_name(@actor, 0, 0)
#draw_actor_level(@actor, 45, 0)
draw_actor_hp(@actor, 112, -6, 102)
#draw_exp(@actor, 0, 60, 102)
#draw_actor_mp(@actor, 55, 17, 48)
draw_actor_mp(@actor, 112, 14, 102)
#==========Make the Adjustment here if you edited the GOLD variable to be longer than 1 Character===============
contents.font.size = Font.default_size
#draw_currency_value(@gold, GOLD, 0, 82, 102)
#draw_currency_value(Gold Variable, Term Variable, X-pos, Y-Pos, Width) change the width if you make the term longer than 1 char
#example, draw_currency_value(@gold, GOLD, 0, 155, 110)
#==========Make the Adjustment here if you edited the GOLD variable to be longer than 1 Character===============
end
#-----------------------------------------------------
# * Update * used to keep things up to date
#-----------------------------------------------------
def update
super
self.visible = $game_switches[SWITCH]
return if !self.visible
if @level != @actor.level or @hp != @actor.hp or @mp != @actor.mp or
@tp != @actor.tp or @exp != @actor.exp or @gold != $game_party.gold
refresh
end
end
#-----------------------------------------------------
# * Custom Definition for the experience bar free to use if you like
#-----------------------------------------------------
def draw_exp(actor, x, y, width = 124)
s1 = @actor.max_level? ? "---------" : @actor.exp
s2 = @actor.max_level? ? "---------" : @actor.next_level_exp - @actor.exp
if @actor.max_level? ? draw_gauge(x, y, width, 1, exp_gauge_color1, exp_gauge_color2)
:
draw_gauge(x, y, width,(((actor.exp.to_f/100) / (actor.next_level_exp.to_f/100)) * 100),
exp_gauge_color1, exp_gauge_color2)
end
change_color(system_color)
#draw_text(x, y, 30, line_height, EXPTERM)
change_color(text_color(27))
if @actor.max_level? ? draw_text(x + width - 72, y, 72, line_height, "------------", 2)
:
draw_text(x + width - 72, y, 72, line_height, actor.next_level_exp.to_i - actor.exp.to_i, 2)
end
end
end
#------------------------------------------------------
# * Scene_Map Class, For keeping it on the map
#------------------------------------------------------
class Scene_Map < Scene_Base
alias start_window start
alias term_window terminate
alias update_window update
def start
start_window
@winhud = Window_Hud.new
update
end
def terminate
@winhud.dispose
term_window
end
def update
update_window
@winhud.update
end
end
[/Spoiler]
If this becomes too much of a pain, I can always have it in the middle of the screen, as stark posted. The only downside to that is that it likes to cover my events (but the background has enough opacity that I don't think it would look off).
Thanks again, guys! ;_;
Okay I'm pretty sure this will work, but I didn't test it. (Haven't really used ace, so I don't feel comfortable in it)
[spoiler]# Create variable
$hud_window_patch = false
# Create a check for window visibility
class Window_KeyItem < Window_ItemList
alias hud_window_patch_update update
def update
# $hud_window_patch returns true
# if the KeyItem window is visible
$hud_window_patch = true
hud_window_patch_update
end
alias hud_window_patch_clear clear_heading
def clear_heading
$hud_window_patch = false
hud_window_patch_clear
end
end
class Scene_Map < Scene_Base
alias hud_map_patch_update update
def update
hud_map_patch_update
@hud_check = $game_switches[Hud_config::SWITCH]
@winhud.visible = ($hud_window_patch) ? false : @hud_check
@winhud.update
end
end
[/spoiler]
Let me know if any errors occur or anything of the sort!
Hmmm... Maybe I set something up wrong? ;9
I loaded the map and the HUD contents were gone already. ;_; The background picture that I summoned via events is still there, though. Whenever I close the item window, the contents of the HUD flash on for a second and then go away again. ;9
[Spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FM0BderG.png%3F1&hash=e547453c4f7e2baf4bc772c3036fb4375719e4b1)[/Spoiler]
Haha I was afraid something like that would happen. There shouldn't be any extra set up on your part, I just goofed. I will fix it in a while, as im doing some graphic work right now. In the mean time feel free to use the other patch and I will load this up in vxa to fix it :)
Edit:
kay it should be fixed. At least, it does what i wanted o.o
[spoiler]# Create variable
$hud_window_patch = false
# Check if the window is active
class Window_KeyItem < Window_ItemList
alias hud_window_patch_update update
def update
# $hud_window_patch returns true
# if the KeyItem window is active
$hud_window_patch = (self.active) ? true : false
hud_window_patch_update
end
alias hud_window_patch_clear clear_heading
def clear_heading
$hud_window_patch = false
hud_window_patch_clear
end
end
class Scene_Map < Scene_Base
alias hud_map_patch_update update
def update
hud_map_patch_update
@hud_check = $game_switches[Hud_config::SWITCH]
@winhud.visible = ($hud_window_patch) ? false : @hud_check
@winhud.update
end
[/spoiler]
Hey, that worked!! :tpg:
I can use event calls in it, right? If that makes sense, haha. There were a couple of other things related to the common event that I might need to add in.
[Spoiler=such as]
-Erasing picture 1 (the HUD bg) when the window pops up and restoring picture 1 afterwards
-checking a variable and then tinting picture 1 based on that variable (I let the players set their own windowskin/HUD colors and set up some picture tints).
[/Spoiler]
Either way, thanks for everything you guys have done! ;o;
Yes if you want to use it in a common event, you can use the script condition: $hud_window_patch to check if the key item window is active.
Ex:
conditional branch : $hud_window_patch == true
erase picture 1
else
show picture 1
end
Sorry for the late reply! :-) I'm going to try to experiment with it some more in a bit.
Are you still using the pokemon system? If you want, I would be honored to give you a free pokemon of your choosing for your efforts! :)
:o Thanks that's cool, but I seem to have most of the ones I like already maybe a taillow?
Thanks again! The Pokemons have been sent! :-)
Taillow was gifted to User Chaos_Zexion
Shiny Taillow was gifted to User Chaos_Zexion
thanks <3
are....are those for mistvale? ;o;
Not quite, but...close! B) I really liked the concept of Mistvale, but there was something missing (mostly the characters I came up ;9). So, I'm going with something a little different haha, at least, different characters. Those are actually placeholder faces. ;o