|
| 19 Jun 2015 03:13 PM |
What i did is
local text = "hello world";
text:sub(1,1) = "b" -- it errors.
help pls..
AND WHAT IS POINT OF [Q] SERIOUSLY |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 03:16 PM |
Try this
local Text = "Testuinnnnn"
string.sub(Text,1,1) = "v"
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
camhorto
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 32 |
|
|
| 19 Jun 2015 03:20 PM |
| It's probably a habit from other languages, specifically C-like ones. It works with Lua. |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 03:20 PM |
a = 1 a = 1;
a = 1 ; b = 1
is fine
a = 1 b = 1 ugly
well look at wiki there was article ,thats how mine scripting looks |
|
|
| Report Abuse |
|
|
EgoMoose
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 2896 |
|
|
| 19 Jun 2015 03:21 PM |
That's because that's not what string.sub does.
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.sub
It returns the substring given the indexes provided. It doesn't actually substitute.
|
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 19 Jun 2015 03:22 PM |
No, don't try that. string.sub only returns the first letter; you can't change it through string.sub. Try this:
text = text:gsub(".", "b", 1)
gsub replaces the occurrences of http://wiki.roblox.com/index.php?title=String_patterns The first argument is the pattern to replace ("." means any character), the second is what to replace it with, and the third is how many occurrences to replace (the first one, in this case). There are multiple ways to do what you requested, by the way; this is just one option. |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Jun 2015 03:34 PM |
| That's not a habit because I don't do it |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 03:37 PM |
| Worded that incorrectly but that's still not a habit |
|
|
| Report Abuse |
|
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
|
| 19 Jun 2015 03:38 PM |
| Could string.match do the same? |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 19 Jun 2015 05:35 PM |
| http://pastebin.com/Qndiff7n |
|
|
| Report Abuse |
|
|