Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Attempting to learn RGSS

Ok, so I am going to try to learn a lot more RGSS than I already know, which as it seems, is not all that much.

I am using Shark_Tooths window tutorial, and already I have a problem:

#----------------------------------------
# Scene_SkillSystem
#----------------------------------------

class Window_SkillSystem < Window_Base
#----------------------------------------
# Object Initialization
#----------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32
refresh
end <-- Line 12, Syntax Error.

def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(50, 50, 200, 32, Non Combat Skills)
end
end

I tried adding an extra end (using my erm... initiative) but that didn't solve it.

Sorry about this...
 
First use The code tag!
Second the error is not on that line.
Third the error is that you missed one parethesys in the line above, in the refresh line...
Code:
#----------------------------------------
# Scene_SkillSystem
#----------------------------------------

class Window_SkillSystem < Window_Base
#----------------------------------------
# Object Initialization
#----------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32 #<= here you missed the parenthesys
refresh <-- here was the error!
end 

def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(50, 50, 200, 32, Non Combat Skills)
end
end

Here is the right one!
Code:
#----------------------------------------
# Scene_SkillSystem
#----------------------------------------

class Window_SkillSystem < Window_Base
#----------------------------------------
# Object Initialization
#----------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32) 
refresh 
end 

def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(50, 50, 200, 32, Non Combat Skills) #<= you need to define this, if it is a var or if it is text you forgot the "", it will give you an error.
end
end

Hope it helps, and you will get another error if you dont say what "non combat skills" are, unless this is just a script part!.
;) keep going!

Man i have edited this 4 times, so many mistakes I have made lol
 
Thank you so much for your help.

Erm... another noobish moment.

Code:
#----------------------------------------
# Window_SkillSystem
#----------------------------------------

class Window_SkillSystem < Window_Base
  #----------------------------------------
  # Object Initialization
  #----------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    self.contents.draw_text(20, 20, 200, 32, "Non Combat Skills")
    #Displays the icon for the first skill
    @bitmap = RPG::Cache.icon("001-Weapon01.png", 0)
    self.contents.blt(70, 90, @bitmap, Rect.new(0, 0, 22, 22), 160)
  end
end

Line 23, it says "Wrong number of arguments, 2 for 1"... That's the line which says:
@bitmap = RPG::Cache.icon("001-Weapon01.png", 0)
 
That simply means you used two arguments (argument 1: 001-Weapon01; argument 2: 0) for a syntax that requires exactly 1 argument. The 0 is totally unneccessary, so delte it and the comma, and you'll be fine.
 
Thanks so much for your help.

Edit: One last thing that I couldn't find anywhere on these forums...

Say I wanna put this in some text:

"Fishing: level (variable 0019), exp: (variable 0020) out of (variable 0021)"

what would I put?
 
Code:
mylevel [color=lightblue]=[/color] $game_variables[20]
levels [color=lightblue]=[/color] $game_variables[21]
[color=blue]self[/color].contents.draw_text(x,y,width,heigth, [color=purple]"Fishing: level #{mylevel}/#{levels}"[/color])
 
I have put them in def refresh.

This is the script:

Code:
#----------------------------------------
# Window_SkillSystem
#----------------------------------------

class Window_SkillSystem < Window_Base
  #----------------------------------------
  # Object Initialization
  #----------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    self.contents.draw_text(20, 20, 200, 32, "Non Combat Skills")
    #-----------------------------------------------
    #Variables used in the skill systems
    #-----------------------------------------------
    
    #Fishing
    fishlvl = $game_variables[8]
    fishexp = $game_variables[9]
    fishneeded = $game_variables[7]
    #Cooking
    cooklvl = $game_variables[26]
    cookexp = $fame_variables[28]
    cookneeded = $game_variables[27]
    #Hunting
    huntlvl = $game_variables[29]
    huntexp = $game_variables[31]
    huntneeded = $game_variables[30]
    #Alchemy
    alclvl = $game_variables[32]
    alcexp = $game_variables[34]
    alcneeded = $game_variables[33]
    #Agility
    agilvl = $game_variables[35]
    agiexp = $game_variables[37]
    agineeded = $game_variables[36]
    
    #------------------------------------
    self.contents.draw_text(100, 87, 400, 32, "Fishing: level #{fishlvl}, exp #{fishexp}/#{fishneeded}")
    self.contents.draw_text(100, 127, 400, 32, "Cooking: level #{cooklvl}, exp #{cookexp}/#{cookneeded}")
    self.contents.draw_text(100, 167, 400, 32, "Hunting: level #{huntlvl}, exp #{huntexp}/#{huntneeded}")
    self.contents.draw_text(100, 207, 400, 32, "Alchemy: level #{alclvl}, exp #{alcexp}/#{alcneeded}")
    self.contents.draw_text(100, 167, 400, 32, "Agility: level #{agilvl}, exp #{agiexp}/#{agineeded}")
    #Displays the icon for the first skill
    @bitmap = RPG::Cache.icon("fish.png")
    self.contents.blt(70, 90, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)
    @bitmap = RPG::Cache.icon("fo8.png")
    self.contents.blt(70, 130, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)
  end
end
 
When I first saw my name, i thaught there was an error with my tut..>_>

Anyways;

You spelled $game_variables wrong;

cookexp = $fame_variables[28]

XD, fame...

@Chaosg1;
He is probably saving the variables from game. Its esier.
 
Lol, thanks, I suppose I should probably check for typos next time.

Can I ask a question? Why to use game variables and not script variables like @fishing with would be simple...

I already have the system for the skills setup with events, so I already have the variables made.

Edit:

Yay, it is working now.
Finished result:

http://img.photobucket.com/albums/v108/dudemaster/screenieskills.png[/IMG]
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top