LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



Go to page : Previous  1, 2, 3, 4, 5  Next

View previous topic View next topic Go down Message [Page 3 of 5]

The only one
The only one
#21 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
Ok! Like that?

Code:
end #end of class woodcutting

class Game_Party < Woodcutting
def woodcutting
$game_party.woodcuttinglvl = woodcutting_lvl
end
end

or this?
Code:
class Game_Party < Game_Party
def woodcutting
$game_party.woodcuttinglvl = woodcutting_lvl
end
end
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#22 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
neither, the first would error because game party would be using woodcutting class as a super, not what you want. the second would error because your using a child class as the adult class for the same class.

just a simple "class Game_Party" is all you need. and for the wood cutting level, you just need to make an attr_accessor for woodcutting level variable created in the "def initialize".

that way you can check or change the value of the variable by using $game_party.woodcutting_level.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#23 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
I don't know why I did'nt think to that. Cool

Code:
class Game_Party
def initialize
attr_accessor :woodcutting_lvl
lumbering = woodcutting_lvl
$game_party.lumbering
end
end
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
The only one
The only one
#24 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
I get "undefine method attr_accessor for Game_Party#(some number and letters)" when I press on New game.
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#25 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
the attr_accessor is defined in the class its self not the def.

Code:

class Game_Party
  def initialize
    attr_accessor :woodcutting_lvl # <-----
    lumbering = woodcutting_lvl
    $game_party.lumbering
  end
end

instead you need to do it here, or any place in the class so long as its not located inside any def.

Code:

class Game_Party
  attr_accessor :woodcutting_lvl # <-----

  def initialize
    lumbering = woodcutting_lvl
    $game_party.lumbering
  end
end

Also you need to create a class variable not an instance. (defined by a @ symbol.)

Code:

class Game_Party
  attr_accessor :woodcutting_lvl

  def initialize
    lumbering = woodcutting_lvl # <-----
    $game_party.lumbering
  end
end

like this.
Code:

class Game_Party
  attr_accessor :woodcutting_lvl

  def initialize
    @lumbering = woodcutting_lvl # <-----
    $game_party.lumbering
  end
end
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#26 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
I have a lot to learn. Twisted Evil
But I get undefine method lumbering for game_party class. But, it's not a method. it's a variable. Do I need to define it like:
Code:
def lumbering
@lumbering = woodcutting_lvl
end
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#27 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
no you need to create the variable.

Code:

class Game_Party
  attr_accessor :woodlvl
 
  alias :wood_init :initialize
  def initialize
    wood_init
    @woodlvl = 0
  end
end

something like that.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#28 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
I'll read about alias cause I didn't read something about that. If I understand the little part of code, it's this?

alias :wood_init :initialize
def initialize
wood_init
@woodlvl = 0
end
end

The yellow call the initialition method and the green, the define.


But I have a tutorial about alias.
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#29 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
yea the alias is like a def that is called so say initialize, then like intercepted. So say something like this, you look for when initialize is called and then you tell it to use this method first then when you use the alias (your yellow word) it will call the original initialize.

make sense?
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#30 Lumberjack script. In progress again... - Page 3 Empty Re: Lumberjack script. In progress again...
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
Nice, I start to be good! I understand something that I did'nt read about. cheers

I'll need to do like that, no?

Code:

class Game_Party
  attr_accessor :woodcutting_lvl
 
  alias :woodcutting_init :initialize
  def initialize
    woodcutting_init
    @lumbering = 0
    @lumbering = woodcutting_lvl
  end
end

But I don't understand why you extend the woodcutting with "_init". That call the original woodcutting class when I define thw woodcutting_lvl variable. But why "_init"?
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 3 of 5]

Go to page : Previous  1, 2, 3, 4, 5  Next

 

Chatbox system disabled
Personal messaging disabled