when writing a menu is there a way to menu options go from left to right rather than up to down, and if so what is the code to do so.also what code would i use to display an icon in the menu options (aka s1, s2)edit2:
im leaving this open for futer questions
edit3:
question1: how do i get my custom menu to open when esc is pressed?
question2: Is there a way to make a second menu in the same scene?question 4 im have ing a problem with the below code
exp_con = Sprite.new
exp_con.bitmap = Bitmap.new(100, 22)
exp_con.x = 37 #87 - (exp_con.bitmap.width / 2)
exp_con.y = @face.src_rect.height + (exp_con.bitmap.height * 4)
exp_con.z = 101
exp_con.bitmap.fill_rect(0,0,98,18, Color.new(255,255,255))
exp_con.bitmap.fill_rect(2,2,94,14, Color.new(0,0,0))
exp_bar = Sprite.new
exp_bar.bitmap = Bitmap.new(94,14)
exp_bar.x = exp_con.x + 2
exp_bar.y = exp_con.y + 2
exp_bar.z = exp_con.z
exp_bar.bitmap.font.name = ["Centaur", "Tahoma"]
exp_val = $game_party.actors[0].exp
exp_bar.bitmap.clear
exp_barlength = (94 * exp_val) / $game_party.actors[0].rest_exp
exp_color = Color.new(0,0,255)
exp_bar.bitmap.fill_rect(0,0,exp_barlength,20, exp_color)
exp_str = "EXP"
exp_rect = exp_bar.bitmap.text_size(exp_str)
exp_rect.x = (exp_bar.bitmap.width / 2) - (exp_rect.width / 2)
exp_rect.y = (exp_bar.bitmap.height / 2) - (exp_rect.height / 2)
exp_bar.bitmap.font.color = Color.new(0,0,0)
for xo in [-1, 0, 1]
for yo in [-1, 0, 1]
exp_bar.bitmap.draw_text(exp_rect.x + xo, exp_rect.y + yo, exp_rect.width, exp_rect.height, exp_str)
end
end
exp_bar.bitmap.font.color = Color.new(255,255,255)
exp_bar.bitmap.draw_text(exp_rect, exp_str
the problem is with this line here
exp_barlength = (94 * exp_val) / $game_party.actors[0].rest_exp
or more specifically the end of it I need to know the word/syntax/proper-way-of-saying- the actors "exp-required-for-the-next-level"
here is 1 Blizzard made
#==============================================================================
# ** Window_HCommand
#------------------------------------------------------------------------------
# This window deals with general command choices, but the display is
# horizontal.
#==============================================================================
class Window_HCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
super
self.width, self.height = commands.size * width + 32, 64
@column_max = commands.size
self.contents.dispose
self.contents = Bitmap.new(self.width - 32, self.height - 32)
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(i, color)
self.contents.font.color = color
w = (self.width - 32) / @column_max
x = i % @column_max * w
rect = Rect.new(x, 0, self.contents.width / @column_max, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[i], 1)
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = (self.width - 32) / @column_max
# Calculate cursor coordinates
x = @index % @column_max * cursor_width
# Update cursor rectangle
self.cursor_rect.set(x, 0, cursor_width, 32)
end
end
thank you
There's also Window_CommandHorizontal from RMX-OS.
#==============================================================================
# Window_CommandHorizontal
#------------------------------------------------------------------------------
# This window deals with general command choices, but the display is
# horizontal.
#==============================================================================
class Window_CommandHorizontal < Window_Command
#----------------------------------------------------------------------------
# Initialization.
#----------------------------------------------------------------------------
def initialize(width, commands)
super
self.width, self.height = commands.size * width + 32, 64
@column_max = commands.size
self.contents.dispose
self.contents = Bitmap.new(self.width - 32, self.height - 32)
refresh
update_cursor_rect
end
#----------------------------------------------------------------------------
# Draws one item.
# i - item index
# color - text color
#----------------------------------------------------------------------------
def draw_item(i, color)
self.contents.font.color = color
w = (self.width - 32) / @column_max
x = i % @column_max * w
rect = Rect.new(x, 0, self.contents.width / @column_max, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[i], 1)
end
#----------------------------------------------------------------------------
# Updates the cursor rectangle.
#----------------------------------------------------------------------------
def update_cursor_rect
# if no cursor position
if @index < 0
self.cursor_rect.empty
return
end
# match rows
row = @index / @column_max
self.top_row = row if row < self.top_row
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
# set cursor position
cursor_width = (self.width - 32) / @column_max
x = @index % @column_max * cursor_width
self.cursor_rect.set(x, 0, cursor_width, 32)
end
end
I think that I slightly improved the code since I can't see much difference on first sight.
question 5: (and a bump so it gets awnsered)
is it posible to script somthing so that when you click on a sprite/bitmap(not a menu item) of some kind you can execute an action( aka opening a menu and what nots)?
question6:
is it possible to track mouse x and y movments through a specific area. (think mount and Blade (for thoes that know of it))
Question 5
yes and no you can make a selectable window with a selectable bitmap
Question 6
yes thats how the mouse selector works check out in area i believe thats what it is called in the mouse script
thanks
question 7:
if i wanted to make a script that would detect keyboard presses (mouse clicks too) and then make it work with blizz's mouse controller where should i start (reference,resource,and otherwise).
Get tons of add-ons, and turn on the Custom Controls script.
Then use these in conditional branches
Input.trigger?(Input::Key['Letter Here'])
It also has mouse buttons.
how would i use that in a script i tried using an if statment but it never executed my if stztment was
class Z_scene
def main
loop do
if Input.trigger?(Input::Key[';']) then
print "key test works"
end
end
end
end
Quote from: M3T41 AG3 on May 23, 2010, 01:32:47 pm
how would i use that in a script i tried using an if statment but it never executed my if stztment was
class Z_scene
def main
loop do
if Input.trigger?(Input::Key[';']) then
print "key test works"
end
end
end
end
Why use
if REQUIREMENT then
DO THIS
end
?
'then' is only for this
if REQUIREMENT then DO THIS end
(as far as I know)
removing the then doesnt work either.
Quote from: M3T41 AG3 on May 24, 2010, 09:46:37 am
removing the then doesnt work either.
Post whole script.
are you calling the class ?
if you are then you also need to update the input
lass Z_scene
def main
loop do
Input.update
if Input.trigger?(Input::Key[';']) then
print "key test works"
end
end
end
end
Quote from: nathmatt on May 24, 2010, 10:06:30 am
are you calling the class ?
if you are then you also need to update the input
lass Z_scene
def main
loop do
Input.update
if Input.trigger?(Input::Key[';']) then
print "key test works"
end
end
end
end
Lol, was just going here to say that. Really!
i added the Input.update but it still does nothing. ...and that is the entire script.
Quote from: M3T41 AG3 on May 24, 2010, 10:21:17 am
i added the Input.update but it still does nothing. ...and that is the entire script.
And how do you call the scene? You should call it this way:
EDIT: This script is a bit better:
class Z_scene
def main
Graphics.transition
loop do
Input.update
Graphics.update
if Input.trigger?(Input::C)
print "key test works"
end
end
Graphics.freeze
end
end
it works i dont know why but it does work much gratitude
You really don't need the 'then' after if branches
Quote from: game_guy on May 24, 2010, 08:15:28 pm
You really don't need the 'then' after if branches
I know :P. Forgot to remove that. I'll edit my version.
I uhh...didn't see if anyone answered this last bit, so erm, the general method to calling to an actor's experience till the next level is this:
Quote@actor.next_rest_exp_s
like in use of this manner:
self.contents.draw_text(480, 64, 84, 32, @actor.next_rest_exp_s, 2)
So...yup.
next_rest_exp_s.
The string form of the experience remaining to the next level!
question 8: im working with this codeclass ICON < Window_Selectable
def initialize
super (1,100,20,20)
end
def update (i)
if Input.trigger?(Input::A)
print i
end
end
end
i have this set with multiple icons on screen they do the same thing but on diffrent characters however whenever the "a" button is pressed all of the icons trigger not just the specific one that was clicked? what can i do to fix this
bump/
is this not possible??
help please
Quote from: M3T41 AG3 on June 10, 2010, 12:34:12 am
bump/
is this not possible??
You need to be a little more specific on what you are doing, or trying to do. I personally have no idea what you are asking. From the sounds of it, you need to be a little more specific on what happens when the A button is pressed. Maybe an example of the code your working with would help... :P
class MYTH_MAIN
def initialize(menu_index=0)
$menu_index = menu_index
end
def main
$battlebackground = Sprite.new
$battlebackground.bitmap = Bitmap.new("Graphics/Battlebacks/#{$game_map.battleback_name}")
$battlebackground.x = 0
$battlebackground.y = 0
$battlebackground.z = 101
$battler = []
@icon = []
$enemy = []
for i in 0...$game_party.actors.size
$battler[i] = Sprite.new
$battler[i].bitmap = Bitmap.new("Graphics/Battlers/#{$game_party.actors[i].battler_name}")
if i == 0 then
$battler[i].x = 10
else
$battler[i].x = $battler[i - 1].x + 150
end
$battler [i].y = 100
$battler [i].z = 101
@icon[i] = ICON.new
@icon[i].x = $battler[i].x + 10
@icon[i].z = 102
end
Graphics.transition
loop do
Graphics.update
Input.update
#update
for i in 0...$game_party.actors.size
@icon[i].update(i)
end
if $scene != self
break
end
end
Graphics.freeze
end
end
class ICON < Window_Selectable
def initialize
super (1,100,20,20)
end
def update (i)
if Input.trigger?(Input::A)
print i
end
end
end
im trying to get the icons to display the action menu (not yet coded) that has all of the actions/commands you can use in battle and form there im just going to let the default battle system take over.
Quote from: M3T41 AG3 on June 19, 2010, 07:10:19 pm
class MYTH_MAIN
def initialize(menu_index=0)
$menu_index = menu_index
end
def main
$battlebackground = Sprite.new
$battlebackground.bitmap = Bitmap.new("Graphics/Battlebacks/#{$game_map.battleback_name}")
$battlebackground.x = 0
$battlebackground.y = 0
$battlebackground.z = 101
$battler = []
@icon = []
$enemy = []
for i in 0...$game_party.actors.size
$battler[i] = Sprite.new
$battler[i].bitmap = Bitmap.new("Graphics/Battlers/#{$game_party.actors[i].battler_name}")
if i == 0 then
$battler[i].x = 10
else
$battler[i].x = $battler[i - 1].x + 150
end
$battler [i].y = 100
$battler [i].z = 101
@icon[i] = ICON.new
@icon[i].x = $battler[i].x + 10
@icon[i].z = 102
end
Graphics.transition
loop do
Graphics.update
Input.update
#update
for i in 0...$game_party.actors.size
@icon[i].update(i)
end
if $scene != self
break
end
end
Graphics.freeze
end
end
class ICON < Window_Selectable
def initialize
super (1,100,20,20)
end
def update (i)
if Input.trigger?(Input::A)
print i
end
end
end
im trying to get the icons to display the action menu (not yet coded) that has all of the actions/commands you can use in battle and form there im just going to let the default battle system take over.
I'll take a look here. At a glance, though, why do you have all the global variables? It would be better to make them public instance variables and create attr_accessors if you need to access them outside the class.
You also do need not set the x and y. Each is 0 already unless it is otherwise defined.
Also, it is not good to have much more than Graphics, Input, and the normal update in the main loop. I see you have the update commented out and have other stuff in there. Just put the other stuff in the update method, and write it like this:
@icons.each {|icon| icon.update}
Check the help menu chapter Enumerable to learn more about that. Once you properly learn how to use iterators, it will open up a lot of different things that you can do. I'll look at this a little more in a little bit and get back to you.
thanks for looking but i just recenly sovled it myself. thanks again though