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.

no super class method?

Nava

Member

im making a script and i have a block in it that is exactly the same as another all except for the text and it gives me the error of super: no superclassmethod `negative' it would be greatly appreciated if some one could please help me.
here is the part of the script
def correct
super(0, 358, 621, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 24
refresh_2
end
and then this part which is identical but leads to a different def
def negative
super(0, 358, 621, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 24
refresh_3
end
 
No, the problem is the super call is being directed at a non-existing method.

Code:
class Parent_Class
  def your_method
    p 'Parent method'
  end
end

class Child_Class < Parent_Class
  def your_method
    super()
  end
end

By Executing the your_method of an object of the Child_Class, the super refers to the method of the exact name in it's parent class (< Parent_Class)


Your problem is (should be), is that either your parent class isn't being defined, or the method name doesn't match.

Code:
class Parent_Class
  def your_method
    p 'Parent method'
  end
end

class Child_Class
  def your_method
    super()
  end
end

^ This would error because the parent class was specified ^

Code:
class Parent_Class
  def your_method
    p 'Parent method'
  end
end

class Child_Class < Parent_Class
  def yourmethod
    super()
  end
end

^ And this wouldn't work because the method names don't match. ^

Post the whole code if you aren't sure about fixing it.
 

Nava

Member

yea i dont understand what you mean this is the whole code

class Number_window < Window_Base

@@password = 3445

def initialize
super(0, 358, 621, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 24
refresh
end


def refresh
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(0, 0, 400, 32, 'Welcome, may I please have your Credentials?')
self.contents.draw_text(0, 25, 400, 32, 'Thank you one moment please...')
x = 0
if x * 53 != @@password
negative
else
correct
end
end


def correct
super(0, 358, 621, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 24
refresh_2
end


def refresh_2
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(0, 0, 400, 32, 'Thank you, the gate is now open.')
end


def negative
super(0, 358, 621, 100)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 24
refresh_3
end


def refresh_3
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(0, 0, 400, 32, 'Im sorry but those credentials arent')
self.contents.draw_text(0, 25, 400, 32, 'valid, please come back and try again')
self.contents.draw_text(0, 50, 400, 32, 'in a moment when the screen refreshes.')
end

end
 
Just Try This:

Code:
class Number_window < Window_Base
  @@password = 3445
  def initialize
    super(0, 358, 621, 100)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = 'Arial'
    self.contents.font.size = 24
    refresh
  end

  def refresh
    self.contents.clear
    self.contents.font.color = text_color(6)
    self.contents.draw_text(0, 0, 400, 32, 'Welcome, may I please have your Credentials?')
    self.contents.draw_text(0, 25, 400, 32, 'Thank you one moment please...')
    x = 0
    if x * 53 != @@password
      refresh_2
    else
      refresh_3
    end
  end

  def refresh_2
    self.contents.clear
    self.contents.font.color = text_color(6)
    self.contents.draw_text(0, 0, 400, 32, 'Thank you, the gate is now open.')
  end

  def refresh_3
    self.contents.clear
    self.contents.font.color = text_color(6)
    self.contents.draw_text(0, 0, 400, 32, 'Im sorry but those credentials arent')
    self.contents.draw_text(0, 25, 400, 32, 'valid, please come back and try again')
    self.contents.draw_text(0, 50, 400, 32, 'in a moment when the screen refreshes.')
  end
end

Not Sure what you are trying to accomplish, but I believe that is a fix to whatever it was doing.
 

Nava

Member

thanx it is appreciated that i get help this time compared to my other 2 posts

this time i didnt get my first message, should i just make that a regular message in the game then call the script? and thats why i need to know how would i change the variable of x with an event im sure you kno and it help you be greatly appreciated :)

does ne one know how to do that?
 
You have to wait 24 hours before bumping a topic.

Perhaps if you explained what exactly you were trying to accomplish (clearly), someone can help you. The coding as a mess so I have no idea the direction this is trying to go.
 

Nava

Member

what i am trying to do is make it so that when i hit the action key on an event that it changes my global variable from 0 and adds one each time you hit it and that it changes it permanently. i have no clue how to do this or even if its possible and i didnt mean to bump i thought that i hit the edit button but im about half-asleep so im srry. but yea if you could help me with that i say thanx in advance
 

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