Input.repeat?( <key> )

Started by fugibo, June 11, 2009, 05:37:43 pm

Previous topic - Next topic

Seox

Quote from: Blizzard on June 22, 2009, 10:20:36 am
Sure, put in methods.

module A
 
  def self.b
    p 'HAI THAR'
  end
 
end

A.b # shows "HAI THAR"


or

module A
 
  def b
    p 'HAI THAR'
  end
  module_function :b
 
end

A.b # shows "HAI THAR"


or

module A
 
  module_function
  def b
    p 'HAI THAR'
  end
 
end

A.b # shows "HAI THAR"


I prefer the very first way because you can instantly see which method has public access.


Well, see, I was referring more to something like THIS:


module Smurf
SKIN_COLOR = Smurf.skin_color

def Smurf.skin_color
case genes
when 1
return 'blue'
when 2
return 'blue'
when 3
return 'blue'
when 3 == 4
return 'yeah, right....  :V '
end
end


>.< can't indent do to lack of ability to tab in the message window. Does that (^) make sense?
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

fugibo

1) Just add two spaces, you don't NEED a tab :P
2) It's not "Smurf.method_name," it's "self.method_name"
3) BTW, case statements don't use ==, they use ===, which is the same as == except when used with certain objects (such as Ranges and Regexps), in which case they are overridden by said object and add in some nice functionality. For example:
Long Comments: ShowHide


a = 1705351351
b = "Hello, my name is Ruth. My friend is Ted.\n"

case a
when 0..1000000 then print "Hello, World!\n" # Fails because 1705351351 is not between 0 and 1000000
when 1000001...1705351351 then print "Hello, World! (Not! I hate you, GTFO!)\n" # Fails because "..." is exclusive
when 1705351350..1705351351 then print "W/e.\n" # Succeeds because ".." is inclusive; if it wasn't it wouldn't be a range :P

Seox

Quote from: Longfellow on June 22, 2009, 10:16:43 pm
1) Just add two spaces, you don't NEED a tab :P
2) It's not "Smurf.method_name," it's "self.method_name"
3) BTW, case statements don't use ==, they use ===, which is the same as == except when used with certain objects (such as Ranges and Regexps), in which case they are overridden by said object and add in some nice functionality. For example:
Long Comments: ShowHide


a = 1705351351
b = "Hello, my name is Ruth. My friend is Ted.\n"

case a
when 0..1000000 then print "Hello, World!\n" # Fails because 1705351351 is not between 0 and 1000000
when 1000001...1705351351 then print "Hello, World! (Not! I hate you, GTFO!)\n" # Fails because "..." is exclusive
when 1705351350..1705351351 then print "W/e.\n" # Succeeds because ".." is inclusive; if it wasn't it wouldn't be a range :P



Thank you.

I know about === and ranges, but have never heard (except for now) to use it otherwise.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

Blizzard

Quote from: Longfellow on June 22, 2009, 10:16:43 pm
2) It's not "Smurf.method_name," it's "self.method_name"


Both works.

@Seox: You have to use "SKIN_COLOR = Smurf.skin_color" after the method was defined because currently you are calling it before it was defined so you will get an "undefined method" error.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Quote from: Blizzard on June 23, 2009, 05:55:35 am
Quote from: Longfellow on June 22, 2009, 10:16:43 pm
2) It's not "Smurf.method_name," it's "self.method_name"


Both works.

@Seox: You have to use "SKIN_COLOR = Smurf.skin_color" after the method was defined because currently you are calling it before it was defined so you will get an "undefined method" error.


True. But given a module named "FooBarDoStuff," self is easier :P

Seox

Quote from: Blizzard on June 23, 2009, 05:55:35 am
Quote from: Longfellow on June 22, 2009, 10:16:43 pm
2) It's not "Smurf.method_name," it's "self.method_name"


Both works.

@Seox: You have to use "SKIN_COLOR = Smurf.skin_color" after the method was defined because currently you are calling it before it was defined so you will get an "undefined method" error.


Woah, so I CAN use methods to define the constants?

Thanks, Blizz! That solves a TON of problems.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

Blizzard

Yes, you can. But only in the initial definition. You can't change the constant later, but you can change what's in it.

A = 1
A = 2 # error
B = []
B.push(4)
B.push(5)
p B # [4, 5]
B.clear
p B # []
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Seox

Quote from: Blizzard on June 23, 2009, 03:31:34 pm
Yes, you can. But only in the initial definition. You can't change the constant later, but you can change what's in it.

A = 1
A = 2 # error
B = []
B.push(4)
B.push(5)
p B # [4, 5]
B.clear
p B # []



So, effectively, you can "cheat out", clearing a constant and THEN changing it? I'm guessing that, if it's possible, it's frowned upon.


And, on topic, I think that Input.trigger? checks for multiple, but not repeating presses. The help file made it sound like that. Just an interesting thought.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

Aqua

Input.trigger? checks for a key stroke.
Sooo if you press '1' 5x...
11111 <--- that will activate it 5x

Blizzard

trigger? # once
press? # hold pressed
repeat? # hold pressed with that weird delay like in typing
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Quote from: Blizzard on June 23, 2009, 03:43:31 pm
trigger? # once
press? # hold pressed
repeat? # hold pressed with that weird delay like in typing


Specifically, it returns once when first pressed, then again 15 frames later, and then every three frames.

(yes, I used your code, Blizz -- I'm far too lazy to experiment with RGSS myself :P)

Blizzard

Every 3? I could have sworn every 2. ._.

And thank you for acknowledging that you use my research results for your answer. That means you quoted me on a scientific basis. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Quote from: Blizzard on June 23, 2009, 06:19:35 pm
Every 3? I could have sworn every 2. ._.

And thank you for acknowledging that you use my research results for your answer. That means you quoted me on a scientific basis. xD


CRAP YES!!! WHAT'S YOUR ERDOS NUMBER?????!!??!?!?!?!?!

Blizzard

IDK. I didn't make the system, but I reverse engineered it so it's probably 1.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Quote from: Blizzard on June 23, 2009, 06:36:18 pm
IDK. I didn't make the system, but I reverse engineered it so it's probably 1.


Uhm.

Wrong Erdos (no guarantee link will work)...?

Blizzard

I don't think so.

QuoteBecause of his prolific output, friends created the Erdős number as a humorous tribute; Erdős alone was assigned the Erdős number of 0 (for being himself), while his immediate collaborators could claim an Erdős number of 1, their collaborators have Erdős number at most 2, and so on. Some have estimated that 90 percent of the world's active mathematicians have an Erdős number smaller than 8 (not surprising in light of the small world phenomenon). It is jokingly said[25] that Baseball Hall of Famer Hank Aaron has an Erdős number of 1 because they both autographed the same baseball when Emory University awarded them honorary degrees on the same day. Erdős numbers have also been humorously assigned to an infant, a horse, and several actors. For details see the Extended Erdős Number Project.

The Erdős number was most likely first defined by Casper Goffman, an analyst whose own Erdős number is 1.[26] Goffman published his observations about Erdős' prolific collaboration in a 1969 article entitled "And what is your Erdős number?"[27]


The question if Erdos is absolute or if anyone can start his own Erdos squence remains. ._.

EDIT: Aaaaaaaaaaaaaaaanyway, you are spamming your own topic. It doesn't matter what my Erdos number is.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.