generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I need help with a script

Previous Thread :: Next Thread 
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:17 PM
When I run this script, it gives me an error, anyone can tell me what is the error?
It's supposed to tell me what 5 + 5 equals.

local function add(a, b) return -(function(a,b) return add(a, -b) end)(-a, b) end print(add(5, 5))

(you get a cookie if you manage to tell me why it doesn't work without running it)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:21 PM
Please, I need help, it's really important. :'(
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:22 PM
Won't this crash your Studio if you use it? o__o
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:23 PM
It does, doesn't it? You lil' troll >:3
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:23 PM
No, why? It'll just do a stack overflow. rofl.

Spaghetti code, I know.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:28 PM
Here's why:

the function to add two numbers uses the function to substract two numbers, which uses the function to add two number. The code would be valid and would work, except that they call eachothers forever.

5 + 5: calls the sub function: 5 + 5 == -(-5 - 5)

To calculate it, you substract the return value of the function sub, but, you need to calculate the substraction, so we call the function add:

-(-5 - 5) == -(-5 + - 5)

To calculate the substraction, we use the addition, then, we substract, etc....

In final, they just call eachothers until the stack is full.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:33 PM
Can't you avoid using a function? o_e

local function add(a, b) return -(-a + -b) end print(add(5, 5))
> 10

If you don't use a function it works perfect D:
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:38 PM
I know, Spectrumw. Rofl. But, then, it'd wouldn't make an error.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:39 PM
But errors are bad ;_; each time the output returns an error a kitten dies. You don't want dead kittens, do you?
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:42 PM
"each time the output returns an error a kitten dies."

Really? =D

while true do
  pcall(function() error() end)
end

Now, I think all the kittens in the world are dead.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:43 PM
> MouseDI_OVERFLOW stack end

Jah! >:D
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:46 PM
? I'm running it with the official Lua engine (the one that doesn't crash only because of a little 'while true do end'), I think all the kittens in the world are dead, since it already shown some billions of errors.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:47 PM
Oh... ;_; -Sadfaic-
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:48 PM
Spectrumw, run this:

for i = 1, math.huge do
pcall(error)
print(i .. " kittens were killed.")
end

You're gonna kill lots of kittens. *trollfaic*
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:49 PM
But I like kittens ;_; they all are like :3 and o3o and *-*. ;___;
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:52 PM
Too bad. I optimized my script to print less and kill more of them and now, it killed over 100 millions of kittens.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:53 PM
That reminds me when you were falling down at light speed ;_; ... KITTENS ;O;
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
24 Jul 2011 11:55 PM
If you want to make a genocide of kittens, run that script, guys. Trust me, you can't believe how much kittens it kills per second. It kills about 10 000 kittens every second... when ran with the official Lua engine. ;o
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
24 Jul 2011 11:58 PM
After killing all the kittens it will start killing mudkips ;_;
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
25 Jul 2011 12:00 AM
I meant, it will start killing tentaquils D:
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Jul 2011 12:02 AM
I think my script is gonna eliminate all the life in the universe. O.O

How much more iterations until it starts killing humans...? >:D

I'll make it so it skips one iteration: my death. That way, I won't die, =D.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
25 Jul 2011 12:03 AM
You are already dead and you don't even know it >:D
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Jul 2011 12:06 AM
No. Right now, it is killing grass. There is so much grass to kill...

Go look outside, guys! You'll see grass disappearing! 8D
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
25 Jul 2011 12:07 AM
Then it will start killing politicals... Trolololololololol you can't never get rid of all of them.
Report Abuse
Ickwad is not online. Ickwad
Joined: 14 Jun 2011
Total Posts: 147
25 Jul 2011 12:26 AM
function add(a, b)
return (a+b)
end

print(add(5, 25)) --> 30
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image