Hello,
I'm new to RGSS. I read some tutorials, read some parts of the scripts and I felt I was ready to try something. I first tried a really simple HUD, and it went pretty good. Now I tried a CMS with alot of Window_Commands. Like: If you select 'Items', you get a second menu next to the first menu with the options 'items' and 'equipment'. But I get a strange error. My script is called Scene_CMS. So I tried to call it with a script: $scene = Scene_CMS.new. I get this error:
undefined method 'main' for Scene_CMS:Class
I made a method called main. So: What did I do wrong.
BTW, I want to find out the most I can myself, so please don't give tips/tell what's wrong with the rest of the script, other than the main error.
Thank you very, very much!
This is my script#==================================================
# CMS
#==================================================
#
# By: SBR*
#
#
#==================================================
# CLASS Scene_CMS Begins
#==================================================
class Scene_CMS
#------------------------------Main---------------------------------------------
def main
#Define Window_Help
@window_help=Window_Help.new
@window_help.x=0
@window_help.y=0
#Define Window_Menu
s1 = "Status"
s2 = "Item"
s2 = "Change BGM"
s3 = "HUD on/off"
s4 = "System"
@window_menu=Window_Command.new(200, [s1,s2,s3,s4,s5])
@window_menu.x=0
@window_menu.y=100
@window_menu.height=380
@window_menu.index=@menu_index
@window_menu.active=true
@window_menu.visible=true
#Define Window_Content
@window_content=Window_Content
@window_content.x=200
@window_content.y=100
#Define Window_Status
s2_1 = "Status"
s2_2 = "Skills"
@window_status=Window_Command.new(200, [s1,s2])
@window_status.x=200
@window_status.y=132
@window_status.height=128
@window_status.active=false
@window_status.visible=false
#Define Window_Hero
actor=game_party.actors
s1 = actor[0].name
if actor.size >= 2 #Set Choices
s2 = actor[1].name
end
if actor.size >= 3
s3 = actor[2].name
end
if actor.size >= 4
s4 = actor[3].name
end
if actor.size == 1 #Set Window Array
choice=[s1]
elsif actor.size == 2
choice=[s1,s2]
elsif actor.size == 3
choice=[s1,s2,s3]
elsif actor.size == 4
choice=[s1,s2,s3,s4]
end
@window_hero=Window_Command.new(200, choice) #Set Window
@window_hero.x=400
@window_hero.y=132
window_height=64 #Set the window height
for i in 0...actor.size
window_height+=32
end
@window_hero.height=window_height
@window_hero.active=false
@window_hero.visible=false
#Define Window_Item
s1 = "Item"
s2 = "Equipment"
@window_item=Window_Command.new(200,[s1,s2])
@window_item.x=200
@window_item.y=164
@window_item.height=128
@window_item.active=false
@window_item.visible=false
#Define Window_System
s1 = "Save"
s2 = "Return to the title screen"
s3 = "Return to the game"
s4 = "Exit the game"
@window_system=Window_Command.new(200, [s1,s2,s3,s4])
@window_system.active=false
@window_system.visible=false
#Set music
if @bgm==nil
Audio.bgm_play("Audio/BGM/026-Town04", 100, 100)
@bgm=0
else
bgm
end
#Update
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
#Close CMS
Graphics.freeze
@window_help.dispose
@window_menu.dispose
@window_content.dispose
end
#------------------------------Receiver-----------------------------------------
def initialize(menu_index=0)
@menu_index=menu_index
end
#------------------------------Update-------------------------------------------
def update
@window_menu.update
if @window_status.active == true #If Window_Status is active
@window_status.update
end
if @window_hero.active == true #If Window_Hero is active
@window_hero.update
end
if @window_system.active == true #If Window_System is active
@window_system.update
end
#Update your help window
case @window_menu.index
when 0
@window_help.update("Show everything about your heroes")
when 1
@window_help.update("Show your items and armors")
when 2
@window_help.update("Change your BGM")
when 3
@window_help.update("Turn your HUD on or off")
when 4
@window_help.update("Save, go to the title screen or exit the game")
end
#---------------If ENTER is pressed...---------------
if Input.trigger(Input::C)
#Play sound
$game_system.se_play($data_system.decision_se)
#MENU
if @window_menu.active == true
case @window_menu.index
when 0
status
when 1
item
when 2
bgm
when 3
hud
when 4
system
end
#STATUS
elsif @window_status.active == true
case @window_status.index
when 0 #Status
@window_status.active=false #Window Status Inactive
@window_hero.active=true #Window Hero Active
@window_hero.visible=true #Window Hero Visible
when 1 #Skills
@window_status.active=false #Window Status Inactive
@window_hero.active=true #Window Hero Active
@window_hero.visible=true #Window Hero Visible
end
#HERO
elsif @window_hero.active == true
case @window_status.index
when 0 #Status
$scene = Scene_Status.new(@window_hero.index)
when 1 #Skills
$scene = Scene_Skill.new(@window_hero.index)
end
#ITEM
elsif @window_item.active == true
case @window_item.index
when 0 #Item
$scene = Scene_Status.new
when 1 #Equipment
$scene = Scene_Equip.new
end
#SYSTEM
elsif @window_system.active == true
case @window_system.index
when 0 #Save
$scene = Scene_Save.new
when 1 #Return to the title screen
$scene = Scene_Title.new
when 2 #Return to the game
$scene = Scene_Map.new
when 3 #Exit the game
$scene = nil
end
end
end
#---------------If ESCAPE is pressed...---------------
if Input.trigger(Input::B)
$game_system.se_play($data_system.cancel_se)
if @window_menu.active == true
exit
elsif @window_status.active == true
@window_status.active=false
@window_status.visible=false
@window_menu.active=true
elsif @window_hero.active == true
@window_hero.active=false
@window_hero.visible=false
@window_status.active=true
elsif @window_item.active == true
@window_item.active=false
@window_item.visible=false
@window_menu.active=true
elsif @window_sysytem.active == true
@window_system.active=false
@window_system.visible=false
@window_menu.active=true
end
end
end
#---------------Menu Choices---------------
#Menu Choice: status
def status
@window_menu.active=false
@window_status.visible=true
@window_menu.active=true
end
#Menu Choice: item
def item
@window_menu.active=false
@window_item.visible=true
@window_item.active=true
end
#Menu Choice: bgm
def bgm
$game_system.se_play($data_system.decision_se)
case @bgm
when 0
Audio.bgm_play("Audio/BGM/012-Theme01")
when 1
Audio.bgm_play("Audio/BGM/023-Town01")
when 2
Audio.bgm_play("Audio/BGM/033-Ship01")
when 3
Audio.bgm_play("Audio/BGM/058-Slow01")
when 4
Audio.bgm_play("Audio/BGM/063-Slow06")
when 5
Audio.bgm_play("Audio/BGM/026-Town04")
end
@bgm=@bgm + 1 % 6
end
#Menu Choice: hud
def hud
$game_system.se_play($data_system.decision_se)
if $my_hud.visible == false
$my_hud.visible=true
$my_hud.update
$hud_will_vis = true
else
$my_hud.visible==false
$hud_will_vis==false
end
end
#Menu Choice: system
def system
@window_menu.active=false
@window_system.visible=true
@window_system.active=true
end
#Exit the menu
def exit
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
$game_map.autoplay
end
end
#==================================================
# CLASS Scene_CMS ENDS
#==================================================
#==================================================
# CLASS Window_Help BEGINS (Help Window)
#==================================================
class Window_Help < Window_Base
def initialize
super(0, 0, 640, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 20
end
def update(help_text)
self.contents.clear
self.contents.draw_text(0, 0, 440, 32, help_text)
end
end
#==================================================
# CLASS Window_Help ENDS (Help Window)
#==================================================
#==================================================
# CLASS Window_Content BEGINS (Content Window)
#==================================================
class Window_Content < Window_Base
def initialize
super(0, 0, 440, 480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
#Show content
for i in 0...$game_party.actors.size
x = 0
y = i * 150
if i >= 2
x = 250
y -= 300
end
actor = $game_party.actors[i]
self.contents.font.color = text_color(6)
self.contents.draw_text(x, y, 200, 32, actor.name)
offset_x=contents.text_size(actor.name).width+10
self.contents.font.color = text_color(4)
self.contents.draw_text(x+offset_x, y, 200, 32, "Lv: " + actor.level.to_s)
draw_actor_hp(actor, x, y+32)
draw_actor_sp(actor, x, y+64)
draw_actor_exp(actor, x, y+96)
end
end
end
#==================================================
# CLASS Window_Content ENDS (Content Window)
#==================================================
And yes, I'm SBR*.
Thanki you!