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.

Need help with a ruby script

Code:
class Spells_Main
  def initialize
   @id = []
   @lvl = 0
   @name = ''
   @icon_name = ''
   @description =''
   @scope=[]
   @scope[0] = 0
   if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
   @occasion=[]
   @occasion[0]= 0
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   @animation1_id = 002
   @animation2_id = 0
   @menu_se = 0
   @common_event_id = 0
   @sp_cost = 0
   @power = 0
   @atk_f = 0
   @eva_f = 0
   @str_f = 0
   @dex_f = 0
   @agi_f = 0
   @int_f = 100
   @hit = 100
   @pdef_f = 0
   @mdef_f = 100
   @variance = 0
   @element_set = 0
   @plus_state_set = 0
   @minus_state_set = 0

 end

 def fire_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '027'
   end
   if @lvl == 2
      @animation2_id = '028' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '029'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl.to_i
   @power= (rand(50))*@lvl.to_i
   @variance= 15*@lvl.to_i
   @element_set= 001
   @description = 'A lvl '+@lvl.to_s+ ' fire spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def ice_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '030'
   end
   if @lvl == 2
      @animation2_id = '031' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '032'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 002
   @description = 'A lvl '+@lvl.to_s+ ' ice spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def thunder_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '033'
   end
   if @lvl == 2
      @animation2_id = '034' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '035'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 003
   @description = 'A lvl '+@lvl.to_s+ ' thunder spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def water_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '036'
   end
   if @lvl == 2
      @animation2_id = '037' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '038'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 004
   @description = 'A lvl '+@lvl.to_s+ ' water spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def earth_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '039'
   end
   if @lvl == 2
      @animation2_id = '040' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '041'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 005
   @description = 'A lvl '+@lvl.to_s+ ' earth spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def wind_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '042'
   end
   if @lvl == 2
      @animation2_id = '043' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '044'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 006
   @description = 'A lvl '+@lvl.to_s+ ' wind spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def light_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '045'
   end
   if @lvl == 2
      @animation2_id = '046' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '047'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= 007
   @description = 'A lvl '+@lvl.to_s+ ' light spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def dark_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill01'
   if @lvl == 1
     @scope[0] = 1
     @animation2_id = '048'
   end
   if @lvl == 2
      @animation2_id = '049' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 9
      @scope[0]=2
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=1
      elsif scope >= 6
      @scope[0]=2
    end  
    @animation2_id = '050'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl
   @variance= 15*@lvl
   @element_set= '008'
   @description = 'A lvl '+@lvl.to_s+ ' dark spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
 def heal_spell
   puts 'Please select a lvl'
   @lvl = gets.chomp
   @icon_name = 'Skill02'
   if @lvl == 1
     @scope[0] = 3
     @animation2_id = '015'
   end
   if @lvl == 2
      @animation2_id = '016' 
      scope = rand(10)
      if scope >= 0
      @scope[0]=3
      elsif scope >= 9
      @scope[0]=4
    end 
       
   end 
    if @lvl >= 3
      scope = rand(10)
      if scope >= 0
      @scope[0]=3
      elsif scope >= 6
      @scope[0]=4
    end  
    @animation2_id = '017'
   end 
    if @scope[0] == 0 
      @scope[1]='Nobody'
   end
   if @scope[0] ==1 
   @scope[1]= 'One Enemy'
   end
   if @scope[0] ==2 
    @scope[1]= 'All Enemies'
    end
   if @scope[0] == 3 
    @scope[1]= 'One Ally'
    end
   if @scope[0] ==  4 
    @scope[1]= 'All Allies'
    end
   if @scope[0] == 5 
    @scope[1]= 'One Dead (hp = 0) Ally'
    end
   if @scope[0] ==  6 
    @scope[1]= 'All Dead (hp = 0) Ally'
    end
   if @scope[0] ==  7 
    @scope[1]= 'User of the Skill'
  end
 @occasion[0]= 1
   if @occasion[0]==0
   @occasion[1]= 'Menu +Battle'
   end
  if @occasion[0]==1 
  @occasion[1]= 'Only Useable in Battle'
  end
  if @occasion[0]==2 
  @occasion[1]= 'Only Useable in Menu'
  end
  if @occasion[0]==3 
  @occasion[1]= 'Not Useable'
   end
   
   @sp_cost = (rand(100))*@lvl
   @power= (rand(50))*@lvl*(-1)
   @variance= 15*@lvl
   @int_f = 50
   #@element_set= 001
   @description = 'A lvl '+@lvl.to_s+ ' heal spell that targets '+@scope[1].to_s+' and can be used '+@occasion[1].to_s
   puts 'What will you name this spell'
   @name=gets.chomp
   Spells_Main::new.print_spells
 end
  def print_spells
   @data= ['id='+ @id.to_s,
'name='+ @name.to_s,
'icon_name=' + @icon_name.to_s,
'description=' + @description.to_s,
'scope=' + @scope[0].to_s,
'occasion=' + @occasion[0].to_s,
'animation1_id=' + @animation1_id.to_s,
'animation2_id=' + @animation2_id.to_s,
'menu_se=' + @menu_se.to_s,
'common_event_id=' + @common_event_id.to_s,
'sp_cost=' + @sp_cost.to_s,
'power=' +@power.to_s,
'atk_f=' + @atk_f.to_s,
'eva_f=' + @eva_f.to_s,
'str_f=' + @str_f.to_s,
'dex_f=' + @dex_f.to_s,
'agi_f=' + @agi_f.to_s,
'int_f=' + @int_f.to_s,
'hit=' + @hit_f.to_s,
'pdef_f=' + @pdef_f.to_s,
'mdef_f=' + @mdef_f.to_s,
'variance=' + @variance.to_s,
'element_set=' + @element_set.to_s,
'plus_state_set=' + @plus_state_set.to_s,
'minus_state_set='+@minus_state_set.to_s ]
   @print = '$data_skills['+@id.to_s+'].'
   @data.each do |dat| 
   puts @print+dat.to_s
  end
 end
 
end
Spells_Main::new.fire_spell
I'm just testing the fire spell right now but when I try to run it it says something about >= comparassion of string with 3 failed. 118 has an error and so does 769. also when i got mad at the error with the >= comparrasion (oh yeah thats line 118) so i made it == and that worked but than when it displayed the stats they were all blank :(. What am i doing wrong ><
 
I bet that your error is Comparision of 3 with String failed or something to that effect make sure you are comparing (and by comparing I mean less than and greater than) an Integer with an Integer or a String with a String or else you will get that error

so try this
Code:
   @lvl = gets.chomp.to_i
 

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