![]() |
Possible to reference Objects with spaces in name?
Has anyone found a way to reference an object that has a space in the name?
I'm trying to work out a project using Item names, but with all of the spaces, I'm finding it impossible to reference them in any manner. Am I screwed? Solved below in reply #4 |
If you can reference it on the lhs you can use quotes:
'Path.Object Name With Spaces.attribute' = value |
I half have working what I want...
I managed to get it to work if I reference the object directly by name, but if I try to use a variable and concatenate them I can't seem to get the desired result. And I would need to do this for my idea to work. I have an object named Test Object with the text element set to: Testing 123 sTest=('Parent.Test Object.text') The above returns the proper string echoed into chat. However the following I cannot seem to find a proper method for. sName=('Long Item Name') The above returns: Parent.Long Item Name.text Have tried a few different alterations with how I concatenate them, but with no luck. I tried setting it to another variable again like: sTest2=('sTest') ... but that did nothing new. |
Okay in response to myself, I think I answered my own question. Seems when trying to explain what you're doing helps yourself figure out the solution :)
Basically I just had to get creative with it. I knew I had to do it in 2 steps, but my brain wasn't quite grasping the method at first. Setup separate objects with the string broken up. code1's object: sTestObj=('Parent. code2's object: .text') Then do this: sString=('Long Item Name') However the problem I don't think I can solve.... Items with apostrophes in their names :( |
Well despite apostrophes (they might have been manageable), I found out that the Map system doesn't support names with spaces.
You can add a POI with spaces, but you cannot delete it via slash command. I tried using quotes to no avail. I even managed to add a category name with a space using quotes, but still wasn't able to delete it. One problem solved, blocked by another! :mad: This would have been so much easier if I could just access item IDs from the Examine window, Lol. |
slash commands that take an input value can often be executed two ways...
/do_something_with foo or do_something_with='foo' You might be able to use the later with a variable containing the concatenation. foo='something' ## 'somethingelsewithspaces' do_something_with=foo |
Here's the PM I sent to Rothgar. It explains more in detail about the problem I ran into.
Quote:
|
So we tackled the map system. The delete command supports pipes:
/map2_delete_poi |Poi Name With Lots of Spaces| CategoryNameThe above works great. Getting the vertical lines | in the code was annoying, but wrapping them in single quotes worked in the end, it was just combing the code altogether that was a PITA. So my next question... Anyone manage to access an element that has both spaces in the name AND an apostrophe? You can see where this would lead to trouble: 'Parent.Parent.Lord's Amulet.attribute' = blah |
LOL... almost every time I ask a question I usually manage to figure it out.
Wrapping it in double quotes worked! "Parent.Lord's Amulet.attribute" = blah |
Code:
'Parent.Parent.Lord's Amulet.attribute' = blah |
hehe I posted the solution above. The reason I needed to do it the way I posted, is because I'm referencing Item names from the in-game examine window.
They have apostrophe's in their name, and there's no way to edit the apostrophe out via scripting. |
Quote:
|
Quote:
|
Yeah you're probably right on that. I do know the parser only makes one pass to for escaped characters though. It won't recursively check until they are all resolved.
|
I usually work in the UIBuilder, so I'm not sure what my above code would look like in XML saved, I'd have to look. Shouldn't really matter though. Long as I go things working, I am happy :D
|
| All times are GMT -5. The time now is 05:29 PM. |
vBulletin® - Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
© MMOUI