Dear all,
In my game I have several menus in which the user will have a list of items to select from - items which will be dynamically defined and, as such, cannot be used as a command menu. So I have to create List menus.
However, when I create said menus, they do not select the first item automatically.
I have used the scripts below in a brand new copy of Scene Maker - just to make sure it is not my fault - with the same results. Can anyone help me?
Script 1:
Script 2:
Script 3:
In my game I have several menus in which the user will have a list of items to select from - items which will be dynamically defined and, as such, cannot be used as a command menu. So I have to create List menus.
However, when I create said menus, they do not select the first item automatically.
I have used the scripts below in a brand new copy of Scene Maker - just to make sure it is not my fault - with the same results. Can anyone help me?
Script 1:
module LunaEngine
module NewScene
# Create new scenes here
# Copy :default scene for configuration attributes
SCENES[:VGM_chooseClassMenu] = {
# Windows list for layout
:windows => [:VGM_chooseClassMenu_list,
:VGM_chooseClassMenu_description],
# Default active window
# Which window will be activated when enter scene
:active => :VGM_chooseClassMenu_list,
} # End :encyclopedia
end #end NewScene
end #end Module
module NewScene
# Create new scenes here
# Copy :default scene for configuration attributes
SCENES[:VGM_chooseClassMenu] = {
# Windows list for layout
:windows => [:VGM_chooseClassMenu_list,
:VGM_chooseClassMenu_description],
# Default active window
# Which window will be activated when enter scene
:active => :VGM_chooseClassMenu_list,
} # End :encyclopedia
end #end NewScene
end #end Module
Script 2:
module LunaEngine
module NewScene
WINDOWS[:VGM_chooseClassMenu_list] = {
:type => :selectable,
:content => nil,
:item_content => :VGM_chooseClassMenu_list_items,
:data => :VGM_chooseClassMenu_list_data,
:enable_item => :default_command_enable,
:x => 0,
:y => 0,
:z => 300,
:width => 240,
:height => 400,
:item_height => 24,
😛adding => 12,
:cursor => true,
:arrow => true,
:align => 0,
:item_rect=> {
:custom => false, # Enable custom item_rect or not? True/False
},
:back_type => 0,
:background_variable => 1,
:type_0 => {
:skin => "Window", # Name of the Windowskin
😮pacity => 255, # Change the transparency of the window.
}
}
HANDLERS[:VGM_chooseClassMenu_list] = {
:cancel => :VGM_chooseClassMenu_list_onCancel,
😮n_change => :VGM_chooseClassMenu_list_onChange,
😮k => :VGM_chooseClassMenu_list_onOk
}
module Data
def VGM_chooseClassMenu_list_data
response = []
$data_classes.each_index do |i|
unless $data_classes.nil?
response.push($data_classes)
end
end
return response
end
end #end Data
module Lunatic
def VGM_chooseClassMenu_list_items(index)
#preparing results
result = []
#item from data
item = data[index]
#get the rectangle (YES, rect STANDS FOR RECTANGLE)
rect = item_rect(index)
rect.width -= 4
if item
icon = nil
name = [
# text
"#{item.name}",
# [offset x, offset y]
[rect.x, rect.y],
# [text width, align]
[rect.width, 0],
# [Red, Green, Blue, Alpha]
[255,255,255,255],
# [Font name, Font size, Bold, Italic]
[Font.default_name, Font.default_size, Font.default_bold, Font.default_italic]
]
result.push(icon, name)
end #end if
result
end
end #end Lunatic
module Handlers
# -----------------------------------------------------------------
# Cancel Handler for :VGM_debugMenu_region_list
# -----------------------------------------------------------------
def VGM_chooseClassMenu_list_onCancel
#~ $VGM_system.player.class = 7
#~ return_scene
end
# -----------------------------------------------------------------
# On Change Handler for :VGM_debugMenu_region_command
# -----------------------------------------------------------------
def VGM_chooseClassMenu_list_onChange
# get response windows
window🙂VGM_chooseClassMenu_description).refresh
end
def VGM_chooseClassMenu_list_onOk
#~ selectedClass = $VGM_menu_temp
#~ $VGM_system.player.class = selectedClass.id
#~ $game_variables[2] = selectedClass.name
#~ return_scene
#~ $luna_active = false
end
end # End Handlers
end #end NewScene
end #end Module
module NewScene
WINDOWS[:VGM_chooseClassMenu_list] = {
:type => :selectable,
:content => nil,
:item_content => :VGM_chooseClassMenu_list_items,
:data => :VGM_chooseClassMenu_list_data,
:enable_item => :default_command_enable,
:x => 0,
:y => 0,
:z => 300,
:width => 240,
:height => 400,
:item_height => 24,
😛adding => 12,
:cursor => true,
:arrow => true,
:align => 0,
:item_rect=> {
:custom => false, # Enable custom item_rect or not? True/False
},
:back_type => 0,
:background_variable => 1,
:type_0 => {
:skin => "Window", # Name of the Windowskin
😮pacity => 255, # Change the transparency of the window.
}
}
HANDLERS[:VGM_chooseClassMenu_list] = {
:cancel => :VGM_chooseClassMenu_list_onCancel,
😮n_change => :VGM_chooseClassMenu_list_onChange,
😮k => :VGM_chooseClassMenu_list_onOk
}
module Data
def VGM_chooseClassMenu_list_data
response = []
$data_classes.each_index do |i|
unless $data_classes.nil?
response.push($data_classes)
end
end
return response
end
end #end Data
module Lunatic
def VGM_chooseClassMenu_list_items(index)
#preparing results
result = []
#item from data
item = data[index]
#get the rectangle (YES, rect STANDS FOR RECTANGLE)
rect = item_rect(index)
rect.width -= 4
if item
icon = nil
name = [
# text
"#{item.name}",
# [offset x, offset y]
[rect.x, rect.y],
# [text width, align]
[rect.width, 0],
# [Red, Green, Blue, Alpha]
[255,255,255,255],
# [Font name, Font size, Bold, Italic]
[Font.default_name, Font.default_size, Font.default_bold, Font.default_italic]
]
result.push(icon, name)
end #end if
result
end
end #end Lunatic
module Handlers
# -----------------------------------------------------------------
# Cancel Handler for :VGM_debugMenu_region_list
# -----------------------------------------------------------------
def VGM_chooseClassMenu_list_onCancel
#~ $VGM_system.player.class = 7
#~ return_scene
end
# -----------------------------------------------------------------
# On Change Handler for :VGM_debugMenu_region_command
# -----------------------------------------------------------------
def VGM_chooseClassMenu_list_onChange
# get response windows
window🙂VGM_chooseClassMenu_description).refresh
end
def VGM_chooseClassMenu_list_onOk
#~ selectedClass = $VGM_menu_temp
#~ $VGM_system.player.class = selectedClass.id
#~ $game_variables[2] = selectedClass.name
#~ return_scene
#~ $luna_active = false
end
end # End Handlers
end #end NewScene
end #end Module
Script 3:
module LunaEngine
module NewScene
WINDOWS[:VGM_chooseClassMenu_description] = {
:type => :base,
:content => :VGM_chooseClassMenu_description_contents,
:x => 240,
:y => 0,
:z => 400,
:width => 400,
:height => 400,
:item_height => 24,
😛adding => 12,
:cursor => true,
:arrow => true,
:align => 0,
:item_rect=> {
:custom => false, # Enable custom item_rect or not? True/False
:width => 64, # Width of the item rect.
:height => 64, # Height of the item rect.
:spacing_ver => 8, # Spacing of each item vertically.
:spacing_hor => 8, # Spacing of each item horizontally.
},
:back_type => 0,
:background_variable => 1,
:type_0 => {
:skin => "Window", # Name of the Windowskin
😮pacity => 255, # Change the transparency of the window.
},
:type_1 => {
:color1 => [0, 0, 0, 128],
:color2 => [0, 0, 0, 128],
:vertical => false,
},
:type_2 => {
😛icture => "commandpane", # Graphics/System
😮pacity => 255,
😮ffset_x => 0,
😮ffset_y => 0,
}
}
module Lunatic
def VGM_chooseClassMenu_description_contents
result = []
item = get_item🙂VGM_chooseClassMenu_list)
if item
#name
result.push([
"#{item.name}", # text
[12, 0], # [offset x, offset y]
[contents.width, 0], # [text width, align]
[255, 161, 61, 255], # [Red, Green, Blue, Alpha]
[Font.default_name, Font.default_size, true, Font.default_italic] # [Font name, Font size, Bold, Italic]
])
end #end if
result
end #end VGM_debugMenu_region_display_contents
end #end Lunatic
end #end NewScene
end #end Module
module NewScene
WINDOWS[:VGM_chooseClassMenu_description] = {
:type => :base,
:content => :VGM_chooseClassMenu_description_contents,
:x => 240,
:y => 0,
:z => 400,
:width => 400,
:height => 400,
:item_height => 24,
😛adding => 12,
:cursor => true,
:arrow => true,
:align => 0,
:item_rect=> {
:custom => false, # Enable custom item_rect or not? True/False
:width => 64, # Width of the item rect.
:height => 64, # Height of the item rect.
:spacing_ver => 8, # Spacing of each item vertically.
:spacing_hor => 8, # Spacing of each item horizontally.
},
:back_type => 0,
:background_variable => 1,
:type_0 => {
:skin => "Window", # Name of the Windowskin
😮pacity => 255, # Change the transparency of the window.
},
:type_1 => {
:color1 => [0, 0, 0, 128],
:color2 => [0, 0, 0, 128],
:vertical => false,
},
:type_2 => {
😛icture => "commandpane", # Graphics/System
😮pacity => 255,
😮ffset_x => 0,
😮ffset_y => 0,
}
}
module Lunatic
def VGM_chooseClassMenu_description_contents
result = []
item = get_item🙂VGM_chooseClassMenu_list)
if item
#name
result.push([
"#{item.name}", # text
[12, 0], # [offset x, offset y]
[contents.width, 0], # [text width, align]
[255, 161, 61, 255], # [Red, Green, Blue, Alpha]
[Font.default_name, Font.default_size, true, Font.default_italic] # [Font name, Font size, Bold, Italic]
])
end #end if
result
end #end VGM_debugMenu_region_display_contents
end #end Lunatic
end #end NewScene
end #end Module