[CityGen] Trying to use City_Gen.module_path
-
I'm sure this is fundamental ruby 101 question and I'm being dense....so nothing new!
I want to make a variable with the path to the "building" folder (not in the program yet, its something I'm playing with). So I figured I could do this:
path = City_Gen.module_path path.concat "/buildings"But everytime I run that, it keeps adding another /buildings onto the end. So I get:
C:/Program Files/Google/Google SketchUp 7/Plugins/citygen/modules/buildings/buildings/buildings/buildings/buildings/buildings/buildingsI figure that each time I ran it, it would return the path, and so the concat would just add /buildings onto the end of the path. I wasn't expecting it to actually modify the @module_path variable.
So what would be the correct way to use City_Gen.module_path so I could append my buildings folder onto it, and not change the @module_path and mess up everything else that depends on that variable remaining constant.
Chris
-
hm... taht's odd.
I thought ruby made a copy when you used the =
What happens if you do:
path = City_Gen.module_path + "/buildings"? -
Ahh, yes that works. I so rarely work with strings, its like my mind turns to mush when I try. Thanks Thom!
Chris
-
path = File.join(City_Gen.module_path,"buildings") -
FYI; if you do a lot of string processing then you might want to use single quotes strings instead of double quoted string. Double quoted strings allows variables inside it and require more processing than single quoted. I'm not that familiar with the performance difference in Ruby, but it's the same in PHP. I've done quite a bit of PHP programming for making websites and then it's always string manipulations so I got into the habit for always using single quoted unless I need variables in my string.
The Su plugins there's usually not that much string processing going on, so I don't think it'll matter that much. -
Advertisement
