Guest Access
Go to page : 1, 2, 3, 4, 5
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Ok! Like that?
or this?
- 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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
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.
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
The only one
profile
NuKa_BuBble
profile
I don't know why I did'nt think to that.
- 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
The only one
The only one
profile
NuKa_BuBble
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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
the attr_accessor is defined in the class its self not the def.
instead you need to do it here, or any place in the class so long as its not located inside any def.
Also you need to create a class variable not an instance. (defined by a @ symbol.)
like this.
- 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
The only one
profile
NuKa_BuBble
profile
I have a lot to learn.
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:
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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
no you need to create the variable.
something like that.
- 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
The only one
profile
NuKa_BuBble
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.
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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
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?
make sense?
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Nice, I start to be good! I understand something that I did'nt read about.
I'll need to do like that, no?
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"?
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
Go to page : 1, 2, 3, 4, 5