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: Converting function input into a string?

Previous Thread :: Next Thread 
DBDude221 is not online. DBDude221
Joined: 31 Jan 2010
Total Posts: 74
18 Apr 2013 05:46 AM
Hiya. Still pretty new to the world of programming.

Lets say I had a function:

function f(x)
return x^2+6x-4
end

Is there any way to convert x^2+6x-4 into a string?? Not the actual answers that satisfy f(x), but the expression itself.

So it would become "x^2+6x-4"

Is this possible without declaring a new variable?
Report Abuse
1WOOF1 is not online. 1WOOF1
Joined: 03 May 2009
Total Posts: 20682
18 Apr 2013 05:58 AM
Use tostring?
Report Abuse
DBDude221 is not online. DBDude221
Joined: 31 Jan 2010
Total Posts: 74
18 Apr 2013 06:00 AM
Unless theres another way around it, the problem what that is as soon as you call f(x), "x" is evaluated and since the function is designed to return the value at x, it just spits out a number
Report Abuse
josh50000 is not online. josh50000
Joined: 29 Nov 2009
Total Posts: 697
18 Apr 2013 06:04 AM
Unless you want to the change the calculation while the game is running, the easiest way would be to:

function f(x)
return "x^2+6x-4"
end
Report Abuse
josh50000 is not online. josh50000
Joined: 29 Nov 2009
Total Posts: 697
18 Apr 2013 06:10 AM
Or did you want:

function f(x)
return x.."^2+6"..x..-4" -- x in the calculation becomes defined from the function arg.
end
Report Abuse
josh50000 is not online. josh50000
Joined: 29 Nov 2009
Total Posts: 697
18 Apr 2013 06:12 AM
x.."^2+6"..x.."-4" -- missed a Speech mark
Report Abuse
DBDude221 is not online. DBDude221
Joined: 31 Jan 2010
Total Posts: 74
18 Apr 2013 06:14 AM
Yes, thanks. Thats exactly what I needed.
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