FoolHater
|
  |
| Joined: 17 Jul 2008 |
| Total Posts: 2141 |
|
|
| 24 Nov 2011 01:25 AM |
I am almost done reading the String Manipulation section of the Function Dump Roblox Wiki article, but is string manipulation as important as coroutines or tables/metatables?
It strings have limited application in scripting "physics." Text/strings do not seem to need a knowledge of complex functions to be manipulated. |
|
|
| Report Abuse |
|
|
FoolHater
|
  |
| Joined: 17 Jul 2008 |
| Total Posts: 2141 |
|
|
| 24 Nov 2011 08:01 AM |
Okay, for example, string manipulation deals with uncommon functions like string.reverse(s), which returns a string that is the string "s" reversed:
print(string.reverse ("!moM ,olleH"))
Will result in: Hello, Mom!
Does it not seems limited in the application of scripting? |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:15 AM |
You don't need to use but if you are comparing strings the safe would upper them both or lower them both and compare. Like this.
function compare(string1,string2) if string1:lower()==string2:lower() then return true else return false end end
compare("ASD",string.reverse("DSA"))
|
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:17 AM |
Opps add
print(compare("asd",string.reverse("DSA"))) |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:18 AM |
local Format = "Current number of players: %d, Tick(): %d" local Msg = Instance.new("Hint",Workspace)
while Msg.Parent == Workspace do Msg.Text = Format:format(#game:GetService("Players"):GetChildren(), tick()) wait() end
~+[CROOKITY BANDED SNAKES]+~ |
|
|
| Report Abuse |
|
|
FoolHater
|
  |
| Joined: 17 Jul 2008 |
| Total Posts: 2141 |
|
|
| 24 Nov 2011 08:21 AM |
So basically strings are limited to comparison and printing messages.
Don't get me wrong, I read the Wiki: string manipulation, patterns, and captures. I just want to know if they are important to my scripts.
By the way, what does tick() do? |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:23 AM |
No they can be used for tables, hold values but they are still useful.
table={} |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:28 AM |
local function usefulfunction() print("Doing something useful...") end
local DumpString = string.dump(usefulfunction) loadstring(DumpString)()
Instance.new("Model",Workspace)
Workspace.Model[string.reverse("evomeR")](Workspace["Model"])
~+[CROOKITY BANDED SNAKES]+~ |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 08:57 AM |
I'll put it this way, once you get into using 'loadstring()' they can become very useful. I've used single strings for databases. The reason a string can be so powerful is because it has no limitations:
str = "1" print(tonumber(str)+1)
str = "true"
str2 = loadstring("return " .. str)
if str2 then str2 = str2() if str2 == true then print("See how much you can do with strings?") end end
|
|
|
| Report Abuse |
|
|
FoolHater
|
  |
| Joined: 17 Jul 2008 |
| Total Posts: 2141 |
|
|
| 24 Nov 2011 09:13 AM |
| How was the string used as a database in your example, Puzzle? |
|
|
| Report Abuse |
|
|