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 » Scripters
Home Search
 

Re: Load a variable to a string?

Previous Thread :: Next Thread 
5943539 is not online. 5943539
Joined: 05 Jan 2010
Total Posts: 810
12 Aug 2011 04:26 PM
I couldn't get but one fail response to this in scripting helpers. So, in anger at that section of forums, I've decided to ask here.

Anyway I'm working on a section of script that sets a variable within loadstring to a matched string. It concatenates the match, but it treats the variable set as a string. i.e:

('x=6\n'):gsub('(%w+)=(.-)%c', function(f,s)
local s=s
pcall(loadstring('s='..s))
end)

Treats s as a string instead of a number. Any possible workarounds?

Math - The origin of all.
Report Abuse
ThisIsSPORE is not online. ThisIsSPORE
Joined: 24 Jun 2011
Total Posts: 2402
12 Aug 2011 04:27 PM
lol why did you call f as a parameter when you didnt need it
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
12 Aug 2011 04:28 PM
gobwey
Report Abuse
5943539 is not online. 5943539
Joined: 05 Jan 2010
Total Posts: 810
12 Aug 2011 04:29 PM
This is a snippet I wrote, from another script I wrote. It doesn't matter, though.

Math - The origin of all.
Report Abuse
ThisIsSPORE is not online. ThisIsSPORE
Joined: 24 Jun 2011
Total Posts: 2402
12 Aug 2011 04:32 PM
('x=6\n'):gsub('(%w+)=(.-)%c', function(f,s)
local s="s"
pcall(loadstring('s='..s))
end)

Report Abuse
5943539 is not online. 5943539
Joined: 05 Jan 2010
Total Posts: 810
12 Aug 2011 04:35 PM
What. You set s to something I can't use anymore.

Math - The origin of all.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
12 Aug 2011 05:11 PM
[ Content Deleted ]
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
12 Aug 2011 05:17 PM
When dealing with stringed numbers do s = s + 0 to turn the string into a number. I hope I understood this right...

~Post here if you're Viet Namese, Canadian or Chinese. I'm from these 3 places. - Some confused kid from Language Center ~
Report Abuse
LPGhatguy is online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
12 Aug 2011 05:19 PM
@aboy5643a
Or, use a better and faster version:

tonumber(s)
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
12 Aug 2011 05:20 PM
Yes, that always works as well.. I always forget that method...

~Post here if you're Viet Namese, Canadian or Chinese. I'm from these 3 places. - Some confused kid from Language Center ~
Report Abuse
5943539 is not online. 5943539
Joined: 05 Jan 2010
Total Posts: 810
12 Aug 2011 05:28 PM
Why doesn't loadstring get locals?

Math - The origin of all.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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