Guest Access
Go to page : 1, 2, 3
Active Member
Active Member
Active Member
profile
handy333
profile
This looks good, I'll have to look at it when I get home. One of the things about alias that bothers me is this:
AKS_LDJA_LKA...
I can't tell if its just random organized code or the actual classes.
AKS_LDJA_LKA...
I can't tell if its just random organized code or the actual classes.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
I don't even know what that is, never seen it before. I googled it and got nothing as a whole, however breaking it up by the underscore in the name i turned up:
https://www.google.com/search?q=LDJA&ie=utf-8&oe=utf-8#q=AKS
http://www.ldja.org/
https://en.wikipedia.org/wiki/Landeskriminalamt
You have a sample of where you found it at?
mr_wiggles
profile
handy333 wrote:This looks good, I'll have to look at it when I get home. One of the things about alias that bothers me is this:
AKS_LDJA_LKA...
I can't tell if its just random organized code or the actual classes.
I don't even know what that is, never seen it before. I googled it and got nothing as a whole, however breaking it up by the underscore in the name i turned up:
https://www.google.com/search?q=LDJA&ie=utf-8&oe=utf-8#q=AKS
http://www.ldja.org/
https://en.wikipedia.org/wiki/Landeskriminalamt
You have a sample of where you found it at?
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
Active Member
profile
handy333
profile
Here's an example of what I mean:
At the top (after the description) there's this:
alias modalg_tempchangestolvl_record_lvl_change change_level
I normally see something like this when I'm referencing some other codes. I'm sure it has something to do with alias.
Are the words that's separated by underscores separate classes or variables or could they just be anything. Then at the end of it there's the change_level separated from it.
- Code:
#--------------------------------------------------------------------------
# * Change Level
# level : new level
# show : Level up display flag
# temp_change : Is it temporary or permanent?
#--------------------------------------------------------------------------
alias modalg_tempchangestolvl_record_lvl_change change_level
def change_level(level, show, temp_change = false)
if temp_change
# Lazy instantiation - it would probably be easier to properly initialize it in
# the initialize method, but for the sake of the example this is better
@temporary_exp = 0 if @temporary_exp == nil
# @exp is current experience, so subtract from it the experience we are being reduced to.
@temporary_exp += @exp - @exp_list[level]
end
modalg_tempchangestolvl_record_lvl_change (level, show)
end
At the top (after the description) there's this:
alias modalg_tempchangestolvl_record_lvl_change change_level
I normally see something like this when I'm referencing some other codes. I'm sure it has something to do with alias.
Are the words that's separated by underscores separate classes or variables or could they just be anything. Then at the end of it there's the change_level separated from it.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
You are correct, but I like to use ' : ' in front of my alias' its cleaner to read, both for you and the computer. It relies on character key elements (flag words).
No they are simply the names of objects. See when you alias you have to move one object, the one your writing over, into memory. Alias does this for you and returns an object name of the clone. This is the first word 'word_one' in the alias. The second points to the object that is being cloned.
This will also only work if the original, word_two, "change_level" has 2 arguments it needs/ asks for. Just extra if you get a "Wrong arguments # for #" Error print.
mr_wiggles
profile
handy333 wrote:
At the top (after the description) there's this:
alias modalg_tempchangestolvl_record_lvl_change change_level
I normally see something like this when I'm referencing some other codes. I'm sure it has something to do with alias.
You are correct, but I like to use ' : ' in front of my alias' its cleaner to read, both for you and the computer. It relies on character key elements (flag words).
Are the words that's separated by underscores separate classes or variables or could they just be anything. Then at the end of it there's the change_level separated from it.
No they are simply the names of objects. See when you alias you have to move one object, the one your writing over, into memory. Alias does this for you and returns an object name of the clone. This is the first word 'word_one' in the alias. The second points to the object that is being cloned.
- Code:
alias :word_one :word_two
This can be cleaned up like so:
Here's an example of what I mean:
- Code:
#--------------------------------------------------------------------------
# * Change Level
# level : new level
# show : Level up display flag
# temp_change : Is it temporary or permanent?
#--------------------------------------------------------------------------
alias modalg_tempchangestolvl_record_lvl_change change_level
def change_level(level, show, temp_change = false)
if temp_change
# Lazy instantiation - it would probably be easier to properly initialize it in
# the initialize method, but for the sake of the example this is better
@temporary_exp = 0 if @temporary_exp == nil
# @exp is current experience, so subtract from it the experience we are being reduced to.
@temporary_exp += @exp - @exp_list[level]
end
modalg_tempchangestolvl_record_lvl_change (level, show)
end
- Code:
#--------------------------------------------------------------------------
alias :record_lvl_change :change_level
def change_level(level, show, temp_change = false)
if temp_change
# Lazy instantiation - it would probably be easier to properly initialize it in
# the initialize method, but for the sake of the example this is better
@temporary_exp = 0 if @temporary_exp == nil
# @exp is current experience, so subtract from it the experience we are being reduced to.
@temporary_exp += @exp - @exp_list[level]
end
record_lvl_change(level, show) # no spaces! ()
end
This will also only work if the original, word_two, "change_level" has 2 arguments it needs/ asks for. Just extra if you get a "Wrong arguments # for #" Error print.
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
Active Member
profile
handy333
profile
I think I'm beginning to get how this work. What can you tell me about attr_accessor?
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
Attr_accessor makes @variables accessible from out side the class object (read and write). attr_reader is 'read' only out of class.
Above is kinda short hand for this:
attr_accessor and attr_reader are just typing short cuts is all.
- Code:
class Attr_Sample
attr_reader :sampleOne
attr_accessor :sampleTwo
def initialize
@sampleOne = 0
@sampleTwo = 0
end
end
class Use_Sample
def initialize
@sample = Attr_Sample.new
print(@sample.sampleOne)
@sample.sampleOne = 2
print(@sample.sampleOne)
print(@sample.sampleTwo)
@sample.sampleTwo = 1 # syntax error no method
end
end
Above is kinda short hand for this:
- Code:
class Sample
def initialize
@sampleOne =0
@sampleTwo =0
end
def sampleOne
return @sampleOne
end
def sampleOne=(value)
@sampleOne = value
end
def sampleTwo
return @sampleTwo
end
end
attr_accessor and attr_reader are just typing short cuts is all.
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
Active Member
profile
handy333
profile
This is great. I've been messing around with both of these and I think I'm starting to get it. I just don't know how to use it for anything.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
that'd be left to your imagination.
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
Active Member
profile
handy333
profile
I mean like ruby in rgss form. I'm not sure how to put the ruby into it. Its like to do something simple you have to have like 200 lines of code.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
Do you have a comparison, you use python?
EVENTALIST
Show Signature
EVENTALIST
Go to page : 1, 2, 3