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  Next

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

Active Member
Active Member
#11 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
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.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#12 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
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
#13 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
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

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
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#14 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
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


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

This can be cleaned up like so:
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
#15 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
I think I'm beginning to get how this work. What can you tell me about attr_accessor?
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#16 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Attr_accessor makes @variables accessible from out side the class object (read and write). attr_reader is 'read' only out of class.
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
#17 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
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
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#18 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
that'd be left to your imagination. Smile
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#19 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
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
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#20 How do I use Alias in RGSSx? - Page 2 Empty Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Do you have a comparison, you use python?
EVENTALIST
Show Signature
EVENTALIST

Sponsored content

profile

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

Go to page : Previous  1, 2, 3  Next

 

Chatbox system disabled
Personal messaging disabled