[VXA] WAIT COMMAND IN RGSS3
Posts
Pages:
1
Through trial and error, I have successfully created an "item find" window for when the player opens a chest or finds treasure. The only problem is, it seems to appear for an indeterminable, almost completely random amount of time.
What I want to do is show it for a fixed amount of time, and then dispose of it, all while the player is able to move around freely.
Is there a command for this, or am I SOL?
What I want to do is show it for a fixed amount of time, and then dispose of it, all while the player is able to move around freely.
Is there a command for this, or am I SOL?
Can you elaborate more on your implementation? My guess is you make your window but there's no reference to it anywhere so when the garbage collector runs it sees your window as an orphaned instance and deletes it from memory.
It doesn't exist as part of any existing menu or "scene"; I call it only from the Script event command (so that I can use it at will and parse in my own variables):
Here is the script itself, if it helps (it's evident I'm only learning how to use this stuff):
$itemno = $game_variables[1]
@itemfind_show = Window_ItemFind.new
Here is the script itself, if it helps (it's evident I'm only learning how to use this stuff):
class Window_ItemFind < Window_Base
def initialize
itemfind_coords
Audio.se_play("Audio/SE/Item1", 75, 100)
super(@window_x, @window_y, @window_width, @window_height)
refresh
end
def itemfind_coords
@window_width = 160
@window_height = 80
@window_x = Graphics.width / 2 - 80
@window_y = Graphics.height / 2 - 40
end
def refresh
contents.clear
draw_itemname
end
def draw_itemname
contents.font.size = 20
@itemname = $data_items[$itemno].name
@itemicon = $data_items[$itemno].icon_index
draw_text(0, 0, @window_width, line_height, 'Found Item:', 1)
draw_icon(@itemicon, 0, line_height + 4)
draw_text(28, line_height + 4, @window_width, line_height, @itemname, 0)
end
def dispose
contents.clear
super
end
end
Yeah, it is garbage collection. The
Makes it an instance on the event interpreter which iirc dies after hitting the end of event code. This makes the window instance orphaned which gets it cleaned up by the GC.
My quick and dirty fix would be to give the window a global reference (so the GC won't kill it) and a frame countdown for when it dies. The Scene_Map update method would have to decrement the countdown in some way. Here's how I'd try it:
Then in an event do
I'm winging it and by itself probably won't work but it should hopefully get the idea across!
*edit*
Probably should dispose old item windows before throwing them into the void to be eated by the GC too.
*reedit*
Disposing the window on a scene change is probably ideal too!
*rereedit*
Fuuuuuuuuuck I forgot Ruby does ifs backwards for single statements.
@itemfind_show = Window_ItemFind.new
My quick and dirty fix would be to give the window a global reference (so the GC won't kill it) and a frame countdown for when it dies. The Scene_Map update method would have to decrement the countdown in some way. Here's how I'd try it:
class Window_ItemFind < Window_Base def initialize @frames_to_die = 180 # 3 seconds of life, vanilla ace is 60 fps itemfind_coords Audio.se_play("Audio/SE/Item1", 75, 100) super(@window_x, @window_y, @window_width, @window_height) refresh end # This will make the window kill itself once the frames to die runs out. # Otherwise it'll assume one frame passed on the map and decrement the counter accordingly def update dispose if @frames_to_die <= 0 @frames_to_die -= 1 end def itemfind_coords @window_width = 160 @window_height = 80 @window_x = Graphics.width / 2 - 80 @window_y = Graphics.height / 2 - 40 end def refresh contents.clear draw_itemname end def draw_itemname contents.font.size = 20 @itemname = $data_items[$itemno].name @itemicon = $data_items[$itemno].icon_index draw_text(0, 0, @window_width, line_height, 'Found Item:', 1) draw_icon(@itemicon, 0, line_height + 4) draw_text(28, line_height + 4, @window_width, line_height, @itemname, 0) end def dispose contents.clear super end end class Scene_Map alias update_itemwindow update unless $@ def update update_itemwindow # Call the original method # See if we have an item window laying around and update it if it isn't disposed $item_window.update if $item_window != nil and not $item_window.disposed? end alias dispose_itemwindow dispose unless $@ def dispose dispose_itemwindow # Gotta make sure we dispose of the window when the map is disposed too else it'll persist between scene changes $item_window.dispose if $item_window != nil and not $item_window.disposed? end end
Then in an event do
$itemno = $game_variables[1] $item_window.dispose if $item_window != nil $item_window = Window_ItemFind.new
I'm winging it and by itself probably won't work but it should hopefully get the idea across!
*edit*
Probably should dispose old item windows before throwing them into the void to be eated by the GC too.
*reedit*
Disposing the window on a scene change is probably ideal too!
*rereedit*
Fuuuuuuuuuck I forgot Ruby does ifs backwards for single statements.
I'm getting this error when the map is drawn:

I copied everything you wrote above pretty much verbatim, so we can reference that if it makes it easier. The error points to this line here:
(I appreciate help thus far, regardless. The official RMVXA forums were no help; one guy just linked me to a bunch of existing scripts)

I copied everything you wrote above pretty much verbatim, so we can reference that if it makes it easier. The error points to this line here:
author=RGSS
alias dispose_itemwindow dispose unless $@
(I appreciate help thus far, regardless. The official RMVXA forums were no help; one guy just linked me to a bunch of existing scripts)
Pages:
1















