|
| 12 Jul 2012 11:04 PM |
This argument wont work!!! Explanation after the script:
s=script.Parent i=s.Head o=s.Torso if string.sub(s.Name, #i.Name + 2, #i.Name + #o.Name + 2) == o.Name then print("This argument does not work.") end
What the if argument is checking, is if the first name INTO the first name, is the second name.
And if i print it in Output the text is "Torso = Torso".
Why doesn't it work in an argument!? Output wont tell me, nor will my prints. |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:06 PM |
Let me make clarify it for you:
s=script.Parent --s.Name = "Head, Torso" |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:07 PM |
s=script.Parent i=s.Head o=s.Torso if string.sub(s.Name, #i.Name + 2, #i.Name + #o.Name + 2) == o.Name then print("This argument does not work.") end
^You can't add string together! Use the .. method instead.
s=script.Parent i=s.Head o=s.Torso if string.sub(s.Name, #i.Name .. 2, #i.Name .. #o.Name .. "2") == o.Name then print("This argument does not work.") end |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:09 PM |
There is a # sign before the string, therefore the value is the number of letters in the string. Thus a numbervalue.
Although I will try that method of connection! Thank you! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:10 PM |
Oops, and #i.Name should be i.Name. Wait, oh I see what you are doing. THe # only works on tables. Use string.len instead
s=script.Parent i=s.Head o=s.Torso if string.sub(s.Name, string.len(i.Name) + 2, string.len(i.Name) + string.len(o.Name) + 2) == o.Name then print("This argument does not work.") end |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:11 PM |
^Sorry, it does the same thing :( *Faceknife* What do you want the script to do again? |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:13 PM |
Just realized, ninja, that you actually implied I was using a string.
string.sub() uses an initial string, an origin number into the string, and the ending number in the string. The first number states what letter the sub starts and the second obviously when it ends. Beginning at 1.
The #Name is the amount of letters in that Name. As for the 2 I stuck in there, that represents the comma and space.
THIS ARGUMENT SHOULD WORK |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:16 PM |
string.len(Name) gives you the number of letters in a Name? Interesting.
As for the comma and space that wasn't included in the original post, the second post is what the initial string is. In case you weren't paying attention.
So it isn't a table per say, it is a Name. A fake table, you could put it.... |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:16 PM |
| Yeah, I realized that. I thought it was something some people just don't catch; apparently I'm some people xD |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:18 PM |
| Your function does work. THe main script has a different problem. |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2012 11:24 PM |
It doesn't though! It is indeed this very argument that wont complete!
Could you test it and see if Output spits out what it want it to? |
|
|
| Report Abuse |
|
|
lmb32
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 63 |
|
|
| 13 Jul 2012 12:12 AM |
| You should use string.match. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2012 02:29 AM |
Thank you! I can not appreciate this enough. For anyone who wants to manipulate a string value for a list and number them, here you go. Thanks for your help!
items = 0 recorded = "" search = script.Parent subject = script.Parent while true do wait(1) if subject.Name == recorded then print("Search completed, subjects recorded.") break end internal = search:GetChildren() for i = 1, #internal do if string.match(subject.Name, internal[i].Name) then items = items + 1 if items == 1 then recorded = internal[i].Name else recorded = recorded..", "..internal[i].Name.."" end print(recorded) Instance.new("BoolValue", internal[i]).Name = "Item #"..items.."" end end wait(0.1) end |
|
|
| Report Abuse |
|
|
lmb32
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 63 |
|
|
| 13 Jul 2012 02:36 AM |
No problem, also check this article:
http://wiki.roblox.com/index.php/String_patterns
Patterns are powerful if you use them correctly. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2012 03:26 AM |
| That's where I went, yes. Thank you. |
|
|
| Report Abuse |
|
|