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: Converting string to numbers

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
03 Apr 2015 02:53 PM
datastore:GetAsync("Position") -- Returns something like "50,10,20" for example

How can I convert this into string, so I can reposition the character based on their last visit?

...Torso.CFrame = CFrame.new(ds:GetAsync("Position"))

Output: Vector3 expected, got string

I have to use cframe because that repositions the whole character, while position doesn't.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
03 Apr 2015 02:59 PM
Could do the following:

Save each axis as it's own number
Read up on string manipulation and figure it out
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
03 Apr 2015 02:59 PM
how about.


Torso.CFrame = CFrame.new(tonumber(ds:GetAsync("Position")))
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
03 Apr 2015 03:00 PM
You don't understand that tonumber can only make a string with NUMBERS a number.
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
03 Apr 2015 03:01 PM
I suggest that save everything not only CFrame.p if i was player when i rejoin game i would like to see my last rotation too
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 03:02 PM
@dark, lemme get dis str8

le~ ',' can't b converted 2 a numbr

wh0 would've fawt dat sumfing clearly not being the following

1, 2, 3, 4, 5, 6, 7, 8, 9, 0, .

could not = a number

xddd
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
03 Apr 2015 03:04 PM
Don't know what that was for, Anime thought otherwise.
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Apr 2015 03:05 PM
If stuido was working I can woop you up a string to position converter


~Commands? Commands. www.roblox.com/Admin-item?id=232183441
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
03 Apr 2015 03:06 PM
@darkmist

I already read up on string manipulation before posting. Please, don't just refer people to it.
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 03:08 PM
@Mr, I take it you would simply use string.find() and use dem %' signs
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Apr 2015 03:11 PM
local nums ={}
for x in string.gmatch(msg, "%d") do
table.insert(nums,x)
end
local pos = Vector3.new(nums[1],nums[2],nums[3])

%d might be wrong
http://wiki.roblox.com/index.php?title=String_patterns#string.match


~Commands? Commands. www.roblox.com/Admin-item?id=232183441
Report Abuse
Bob123456789103570 is not online. Bob123456789103570
Joined: 23 Dec 2008
Total Posts: 9531
03 Apr 2015 03:13 PM
The position is a Vector3.
You may need to break it up; I'll show an example below.

Let's say you have the position
myVector = (1, 2, 3)
You can split this into the 3 coordinates (x, y, z).
myVector.x == 1
myVector.y == 2
myVector.z == 3

Here's where your error comes in. You're passing a string as the argument, but it needs a Vector3 instance. You can create a position with Vector3.new(myVector.x, myVector.y, myVector.z) -- assuming your original value was a vector.

However, should the value be a string initially, you're going to have to do some magic. I don't use Lua, but I may be able to help. From the lua-users wiki, I was able to arrive at the "split" operator.

It goes something like this:

split("a,b,c", ",")

and returns this:

{"a", "b", "c"}

This should be an array, and can be referenced as such. Assuming your "50,10,20" example is how they are formatted, you can merely use the string in the split operator with a comma.

positionArray = split(positionValue, ",")
newPosition = Vector3.new(positionArray[1], positionArray[2], positionArray[3])


This is not a pretty solution, but it should work.
Report Abuse
Bob123456789103570 is not online. Bob123456789103570
Joined: 23 Dec 2008
Total Posts: 9531
03 Apr 2015 03:15 PM
If the split() operator is not available in ROBLOX-based Lua, you will need to use MrJoeyJoeJoey's suggestion to find matches in the string.
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 03:16 PM
ye split() r nawt here m8, dat wood've been a gr00vy feature

;-;-;-;-;
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