- Joined
- Oct 30, 2014
- Messages
- 3
- Reaction score
- 0
- First Language
- English
- Primarily Uses
Salutations!
To begin with I am just a novice at coding, but have been diligently working on it. Please try to use simple terms.
I need assistance with a bit of coding that is most likely quite simple to fix, but I just can't figure it out after days of searching so I will post what I have and any and all assistance with it would be great.
RPG Maker VX Ace.
What I am trying to do:
This is the bit of code I have come up with. What happens for me is it draws the image I want if the var = 0, but even upon changing var[15] it stays the same image (even after refresh)
I already have a window which it places itself in fine, disappears when the window does and overall functions exactly as I'd like EXCEPT the image changing depending on a $game_variables[]
If this is in the wrong topic, or more information is needed, please let me know!
Thank you in advance for the help!
EDIT:
After trying numerous code for the last several months (Though only days after I posted this), I have made a solution!
I have more code in this for myself, but this is the basics of what I needed to be able to make a window that displayed an image based on a variable. You could probably add more arrays/variables to be able to use it for more than one instance as well, however I only need it for this.
Feel free to use this piece of code and edit it freely for commercial and non-commercial use. If you wanna share it, I'd just appreciate some credit.
To begin with I am just a novice at coding, but have been diligently working on it. Please try to use simple terms.
I need assistance with a bit of coding that is most likely quite simple to fix, but I just can't figure it out after days of searching so I will post what I have and any and all assistance with it would be great.
RPG Maker VX Ace.
What I am trying to do:
- Create an image that changes based on an in game variable
def draw_image
if $game_variables[15] = 1
bitmap = Bitmap.new("Graphics/Faces/Image0")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
elsif $game_variables[15] = 1
bitmap = Bitmap.new("Graphics/Faces/Image1")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
elsif $game_variables[15] = 2
bitmap = Bitmap.new("Graphics/Faces/Image2")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end
if $game_variables[15] = 1
bitmap = Bitmap.new("Graphics/Faces/Image0")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
elsif $game_variables[15] = 1
bitmap = Bitmap.new("Graphics/Faces/Image1")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
elsif $game_variables[15] = 2
bitmap = Bitmap.new("Graphics/Faces/Image2")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end
This is the bit of code I have come up with. What happens for me is it draws the image I want if the var = 0, but even upon changing var[15] it stays the same image (even after refresh)
I already have a window which it places itself in fine, disappears when the window does and overall functions exactly as I'd like EXCEPT the image changing depending on a $game_variables[]
If this is in the wrong topic, or more information is needed, please let me know!
Thank you in advance for the help!
EDIT:
After trying numerous code for the last several months (Though only days after I posted this), I have made a solution!
#=====================================================================
# Module Piece to edit
#=====================================================================
module Hud_Config
# Picture = "Graphics/Pictures/test.jpg"
PICTURE = {
0 => "test0.jpg",
1 => "test1.jpg",
2 => "test3.jpg",
}
# Variable to use to determine the picture to display
VAR = 1
end
#=====================================================================
# Create the window
#=====================================================================
class Window_Hud < Window_Base
def initialize
super(0,0,250,75)
update_padding
update_tone
create_contents
refresh
end
def refresh
self.contents.clear
contents.clear
draw_image
def draw_image
bitmap = Cache.picture(Hud_config:
ICTURE[$game_variables[VAR]])
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end
#=====================================================================
# Scene to keep the HUD 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
# Module Piece to edit
#=====================================================================
module Hud_Config
# Picture = "Graphics/Pictures/test.jpg"
PICTURE = {
0 => "test0.jpg",
1 => "test1.jpg",
2 => "test3.jpg",
}
# Variable to use to determine the picture to display
VAR = 1
end
#=====================================================================
# Create the window
#=====================================================================
class Window_Hud < Window_Base
def initialize
super(0,0,250,75)
update_padding
update_tone
create_contents
refresh
end
def refresh
self.contents.clear
contents.clear
draw_image
def draw_image
bitmap = Cache.picture(Hud_config:
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end
#=====================================================================
# Scene to keep the HUD 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
I have more code in this for myself, but this is the basics of what I needed to be able to make a window that displayed an image based on a variable. You could probably add more arrays/variables to be able to use it for more than one instance as well, however I only need it for this.
Feel free to use this piece of code and edit it freely for commercial and non-commercial use. If you wanna share it, I'd just appreciate some credit.
Last edited by a moderator:


