Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 23:37:55 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 [2] 3   Go Down
  Print  
Author Topic: Ruby Discussion and Help -  (Read 1707 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Ashbad
Guest
« Reply #15 on: 17 May, 2011, 00:19:50 »
0

well, it's more of me just practicing the use of lambda expressions Tongue
Logged
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Total Post Ratings: +260

View Profile
« Reply #16 on: 17 May, 2011, 00:37:30 »
0

The only place that I heard about ruby was in RPG Maker XP
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
Ashbad
Guest
« Reply #17 on: 17 May, 2011, 00:40:54 »
0

The only place that I heard about ruby was in RPG Maker XP

how is it used there?  Just curious.
« Last Edit: 17 May, 2011, 00:41:04 by Ashbad » Logged
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Total Post Ratings: +260

View Profile
« Reply #18 on: 17 May, 2011, 00:53:17 »
0

I think the whole scripting is in Ruby, so you can change the configuration and add mods.
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
Ashbad
Guest
« Reply #19 on: 17 May, 2011, 00:54:08 »
0

makes sense -- it's a simple language to learn, but extremely hard to master Smiley
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 22:29:06
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50643


Total Post Ratings: +2640

View Profile WWW
« Reply #20 on: 18 May, 2011, 01:03:07 »
0

Ruby is used in RPG Maker XP and VX. To be honest, though, RM is supposed to be a tool for game creators who don't want to code any single line, so XP purpose was kinda defeated, but by using Ruby you had so much more freedom apparently, although many RPG Maker users had troubles learning it from what I remember.

Also in some versions of XP/VX, the Ruby editor built-in the software used japanese characters. Sad
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Ashbad
Guest
« Reply #21 on: 18 May, 2011, 01:37:16 »
0

I wouldn't be surprised it was hard for them to learn -- it's not a good language to start out with, it took me months to finally declare myself a Ruby Knight, since it's so different from things like C++, Java, BASIC, and the like -- but once you get your foot in the door, the Principle of Least Astonishment (Meaning that if you know the language well, you can decipher and write straightforward code with little trouble) kicks in.

I'm even less surprised they have Japanese characters in a Ruby scripting system -- if it came out before 1999, then it was during the era when 95% of Ruby coding took place in Japan Smiley

Though, it's cool to see that XP and VX used it Cheesy
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 22:29:06
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50643


Total Post Ratings: +2640

View Profile WWW
« Reply #22 on: 18 May, 2011, 01:51:26 »
0

Plus, most RPG Maker users are used to just clicking stuff to insert pre-made events in a pre-made engine. They were not used to code. X.x
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Ashbad
Guest
« Reply #23 on: 18 May, 2011, 02:06:28 »
0

very true.  That's why it's called a 'Maker' Grin though then again, some like Game Maker have somewhat-decent coding abilities.

also, good question from cemetech:

Quote from: christop
Maybe I'm misunderstanding something here (since I don't use Ruby), but couldn't you do exactly the same thing with regular (non-lambda) functions? Or are lambda functions somehow different than regular functions in Ruby? I thought one of the points of lambda functions was the ability to pass a (lambda) function to a second function as an argument, wherein the second function calls the lambda function inside of it. I don't see any of that going on in your code, which would make using lambda functions pointless.

response:

Quote from: Ashbad
I did it purely for practice of point Azn since they can be easily misused, I'm practicing to make sure I have them down right.

Yeah, it's a bit more complex, but they're more useful for higher-level math concepts, and even better for managing code snippets.

EDIT: I only answered part of your question methinks  Shocked so I'll go over how lambda functions can be invaluable:

let's say you have this working piece of code:


1
2
def Exponent(number,root)
   return number**root.to_f;end

if you want to load a variable such as 'Peanut' with an expression like "2 ** 5" you would constantly have to do:


1
Peanut = Exponent(2,5)

which is actually no problem.  But calling to lambdas is a better Ruby approach.  the exact same working code:


1
2
3
Peanut = lambda{|number,root| number**root}

Peanut.call(2,5)

you see, with this method, Peanut is directly attached to the function -- lambda functions are considered actual values, not functions themselves.  This allows for a higher level of abstraction in code, and nesting lambdas can be extremely useful when solving for complex equations -- it's easier to read and keep track of.  Such as in my Quadratic solver (which looks difficult but really is just a simple example of what I'm talking about) -- the lambda function isn't really a function -- it's a value that is determined by calling 'arguments' (I use that loosely, I forgot the true word for it)

This is one way to achieve 'anonymous functions' in Ruby, but actually isn't the most powerful way.  Another way that provides even less hassle is by declaring a Proc Function:


1
2
3
4
5
def ProcExample(input, NUMBAR)
  return lambda {|input| input.chomp.flatten.reverse},
                            lambda {||NUMBAR.to_s.reverse};end

uno, dos = ProcExample

The only real difference between a normal lambda statement and a proc statement is actually usage -- lambdas are when you simply just bind a function to a value.  Procs are when you use them on the fly to return a value based on 'arguments' (again, loosely used) like lambdas, but the difference is that they are usually more block-like and aren't directly bound to an actual variable -- very often seen as arguments of other lambdas or procs or even normal functions, or as returned values (with a lambda, you would return the value by using a call statement, procs would simply be declared at the moment).

I hope that clears a few things up Tongue
Logged
Ashbad
Guest
« Reply #24 on: 16 June, 2011, 04:26:41 »
0

For those interested, this is an awesome compilation of tricks used by advanced Ruby programmers, half I knew, the other half I didn't.  Its very useful: http://www.rubyinside.com/21-ruby-tricks-902.html
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 22:29:06
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50643


Total Post Ratings: +2640

View Profile WWW
« Reply #25 on: 16 June, 2011, 06:49:53 »
0

Cool, hopefully this is useful to some people here.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
aeTIos
You got stair'd!
LV12 Extreme Poster (Next: 5000)
************
Online Online

Gender: Male
Last Login: Today at 23:17:47
Date Registered: 15 September, 2010, 06:00:00
Location: Netherlands, Overijssel
Posts: 3146


Total Post Ratings: +120

View Profile
« Reply #26 on: 16 June, 2011, 14:29:26 »
0

Ruby? Doesnt make sense to me, sorry.
Logged

If something above sounds rude, feel free to vote it down, it was not meant to be rude<<lolol
--Always stay relAXEd!--


Spoiler for Hidden:


[







Spoiler for Still Alive:
This was a triumph.
I'm making a note here: HUGE SUCCESS.
It's hard to overstate my satisfaction.

Aperture Science:
We do what we must because we can.
For the good of all of us
Except the ones who are dead.

But there's no sense crying over every mistake
You just keep on trying till you run out of cake
And the science gets done and you make a neat gun
For the people who are still alive.

I'm not even angry.
I'm being so sincere right now.
Even though you broke my heart and killed me.
And tore me to pieces.
And threw every piece into a fire.
As they burned it hurt because
I was so happy for you.

Now these points of data make a beautiful line
And we're out of beta we're releasing on time.
So I'm GLaD I got burned think of all the things we learned
For the people who are still alive.

Go ahead and leave me.
I think I prefer to stay inside.
Maybe you'll find someone else to help you.
Maybe Black Mesa -
THAT WAS A JOKE. HA HA, FAT CHANCE.
Anyway, this cake is great:
It's so delicious and moist.

Look at me still talking when there's science to do.
When I look out there it makes me GLaD I'm not you.
I've experiments to run there is research to be done
On the people who are still alive

And believe me I am still alive.
I'm doing science and I'm still alive.
I feel FANTASTIC and I'm still alive.
While you're dying I'll be still alive.
And when you're dead I will be still alive.

Still alive
Still alive
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Total Post Ratings: +59

View Profile WWW
« Reply #27 on: 02 July, 2011, 18:32:40 »
+1

Oh, tryruby.org is FAULTY. I tried every single example EXACTLY the same way it was shown in the tutorials, and EVERY TIME I got this:

SyntaxError: <main>:69: syntax error, unexpected $undefined

It showed to enter 4 * 10, and I did. EVERY EXAMPLE shown threw that error when I tried using them in the tryruby built in prompt.

Oh and slightly off topic: EnvisionDev now includes Ruby support.
Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Ashbad
Guest
« Reply #28 on: 02 July, 2011, 18:36:48 »
0

hmm, interesting, I just tried again and it worked.  Perhaps for some reason your browser wasn't compatible with the console?

From what the error was it sounds like it ran into a weird symbol somewhere, which means that it most likely wasn't using ANY of the standard resources.  It should be fine in an actual Ruby script, though.
Logged
Spyro543
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 01:49:00
Date Registered: 15 April, 2011, 01:42:09
Location: Ohio
Posts: 998


Total Post Ratings: +59

View Profile WWW
« Reply #29 on: 02 July, 2011, 18:38:29 »
0

I'll try it in a real Ruby interpreter.
Logged


I own a Compact Computer 40!
Programming languages known: BASIC, C
Favorite Pokemon: Dialga
Favorite games: Super Hexagon, Torchlight II
Pages: 1 [2] 3   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 1.237 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.