Favorite scripting features?

Started by Seox, June 17, 2009, 09:17:29 pm

Previous topic - Next topic

G_G

Again I like how modules can make things simpler like so.
module Gv
  def self.getval(id)
    return $game_variables[id]
  end
  def self.setval(id, val)
    $game_variables[id] = val
  end
  def self.addval(id, val)
    $game_variables[id] += val
  end
  def self.subval(id, val)
    $game_variables[id] -= val
  end
  def self.multval(id, val)
    $game_variables[id] *= val
  end
  def self.divval(id, val)
    $game_variables[id] / val
  end
end


Ok instead of using something like this
$points = $game_variables[id]
you can use this instead
$points = Gv.getval(id)

To me it makes things alot quicker. Here are the different operatoins you can use

Gv.getval(id) # Get the value of the game variable
Gv.setval(id, val) # Set the value of the game variable
Gv.addval(id, val) # Add value to the game variable
Gv.subval(id, val) # Subtract value from the game variable
Gv.multval(id, val) # Multiply value to the game variable
Gv.divval(id, val) # Divide value by the game variable

id = variable id
val = the value you want to set/add/subtract/multiply/divide the variable to

I set modules to do something shorter for me when I know I'm going to be using alot of that command line. I also made on for play sounds so I can use very few letters to make it play a sound

Blizzard

You are overcomplicating this. It's completely unnecessary.
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.

G_G

Well I really dont like typing out $game_variables[id] += or whatever so I shortened it.

Ryex

but your INCREASING process time AND memory usage ADDING FOUR lines of code to get rid of six letters in one line! that's just stupid!
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

fugibo

Quote from: Seox on June 18, 2009, 09:40:22 pm
Quote from: Longfellow on June 18, 2009, 07:17:29 pm
Quote from: Seox on June 18, 2009, 06:20:05 pm
XD


Thank you for the level ^_^

I can see =~ being useful in ruby proper, but not nearly as much in RMXP. What do you use it for, specifically?


Once I used to cheat on a really crappy assignment in Health class. You see, we were supposed to complete a daily journal of our health habbits (or something) for one month. Except, I didn't do it. I also didn't feel like typing up 31 pages of crap I did. So, I made one text file that looked kinda like this:

[month] [day], 2005

6:00: Woke up, [verb1], [verb2] [noun1] for breakfast.
<etc etc for the entire day>


Then came up with some random verbs/nouns and made a Ruby script that detected []'s and filled them in from a hash. Took a tenth of the time doing it manually would've taken, and it was more fun XD


Oh, that's EPIC. I totally have to try that, XD. I wrote a ruby program a while back that acts as flash cards, which I'll use when school starts again. probably never. I can't/don't study. Regardless, pretty cool stuff. It stores missed problems in an array, and then tells you which you missed at the end, too.


I started working on a fairly complex version of that back at the beginning of the year, using Ruby-GNOME2 and REXML (Ruby Electric Extensible Markup Language, part of the standard library). I HATE rote memorization, but we had a ton of that, so...

Seox

Quote from: Longfellow on June 20, 2009, 01:24:11 pm
Quote from: Seox on June 18, 2009, 09:40:22 pm
Quote from: Longfellow on June 18, 2009, 07:17:29 pm
Quote from: Seox on June 18, 2009, 06:20:05 pm
XD


Thank you for the level ^_^

I can see =~ being useful in ruby proper, but not nearly as much in RMXP. What do you use it for, specifically?


Once I used to cheat on a really crappy assignment in Health class. You see, we were supposed to complete a daily journal of our health habbits (or something) for one month. Except, I didn't do it. I also didn't feel like typing up 31 pages of crap I did. So, I made one text file that looked kinda like this:

[month] [day], 2005

6:00: Woke up, [verb1], [verb2] [noun1] for breakfast.
<etc etc for the entire day>


Then came up with some random verbs/nouns and made a Ruby script that detected []'s and filled them in from a hash. Took a tenth of the time doing it manually would've taken, and it was more fun XD


Oh, that's EPIC. I totally have to try that, XD. I wrote a ruby program a while back that acts as flash cards, which I'll use when school starts again. probably never. I can't/don't study. Regardless, pretty cool stuff. It stores missed problems in an array, and then tells you which you missed at the end, too.


I started working on a fairly complex version of that back at the beginning of the year, using Ruby-GNOME2 and REXML (Ruby Electric Extensible Markup Language, part of the standard library). I HATE rote memorization, but we had a ton of that, so...


*prepares to be slapped*
What is rote memorization?
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

fugibo

Quote from: Seox on June 20, 2009, 02:14:59 pm
Quote from: Longfellow on June 20, 2009, 01:24:11 pm
Quote from: Seox on June 18, 2009, 09:40:22 pm
Quote from: Longfellow on June 18, 2009, 07:17:29 pm
Quote from: Seox on June 18, 2009, 06:20:05 pm
XD


Thank you for the level ^_^

I can see =~ being useful in ruby proper, but not nearly as much in RMXP. What do you use it for, specifically?


Once I used to cheat on a really crappy assignment in Health class. You see, we were supposed to complete a daily journal of our health habbits (or something) for one month. Except, I didn't do it. I also didn't feel like typing up 31 pages of crap I did. So, I made one text file that looked kinda like this:

[month] [day], 2005

6:00: Woke up, [verb1], [verb2] [noun1] for breakfast.
<etc etc for the entire day>


Then came up with some random verbs/nouns and made a Ruby script that detected []'s and filled them in from a hash. Took a tenth of the time doing it manually would've taken, and it was more fun XD


Oh, that's EPIC. I totally have to try that, XD. I wrote a ruby program a while back that acts as flash cards, which I'll use when school starts again. probably never. I can't/don't study. Regardless, pretty cool stuff. It stores missed problems in an array, and then tells you which you missed at the end, too.


I started working on a fairly complex version of that back at the beginning of the year, using Ruby-GNOME2 and REXML (Ruby Electric Extensible Markup Language, part of the standard library). I HATE rote memorization, but we had a ton of that, so...


*prepares to be slapped*
What is rote memorization?


You know how sometimes teachers will give you a list of stuff, tell you to memorize it, and call it "teaching?" That's Rote learning. The memorization part is the Rote memorization.

Seox

Nice explanation, thank you ^_^

Yeah, I HATE that crap! It's usually the really dumb teachers, too. And then you're all, WTF? I WANTED TO LEARN THIS CRAP!

/end rant
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

Blizzard

G_G, you can providing an interface for something that needs none.
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

June 21, 2009, 09:29:54 am #29 Last Edit: June 21, 2009, 09:31:51 am by Longfellow
Also, there are assignment operators besides =, GG.


a = 1     # a is One.
a += 2    # a is 3.
a -= 4    # a is -1.
a *= 42   # a is -42.
a /= 1764 # a is -1/42.
a *= -42  # a is 1.
a += 2    # a is 3
a **= 3   # a is 27.
a %= 4    # a is 3.

Seox

Quote from: Longfellow on June 21, 2009, 09:29:54 am
Also, there are assignment operators besides =, GG.

a **= 3   # a is 27. 
a %= 4    # a is 3.




Those last two are "a to the third power", and "a modulo 4", right?

And, aren't _= shortcuts for
a = a _ b
?

Thanks, Longfellow ^_^

(And where did that name and WcW come from, btw? Just curious. They seem random. But so does Seox, so meh.)
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

fugibo

Sí. Now learn

a = 255
a &= 0xf # 15
a |= 0xff # 255
a &= ~0xffffffff # 0

Seox

Quote from: Longfellow on June 21, 2009, 01:49:38 pm
Sí. Now learn

a = 255
a &= 0xf # 15
a |= 0xff # 255
a &= ~0xffffffff # 0



Aren't those unicode, or character binary or something? I'm sorry, and I know that you'll slap me for asking such a blatantly obvious question, but I don't know my way around when it comes to that topic.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

fugibo

Actually, a leading 0x denotes base-16, or hexadecimal. Binary (base 2) can't be typed in most programming languages, and Unicode/ASCII are character encodings.

I'll give you a while longer to figure out the operators yourself ;)