Naming objects while placing them?
by Zergcow · in RTS Starter Kit · 02/28/2008 (10:37 am) · 2 replies
Hey i had an idea to name a building while or after it is place. I was thinking it would be easier to do it after it is placed. Basically i made a UI pop up like the aboutDlg.gui and then i gave it a feild and a button. The button is setup to do this
Just so you know i want to do this so i can place a building, name it, then have the Gui3DprojectionCrtl attach to it based on its name. Exaple is having a gui3DProjectionCtrl for anything starting with "factory_" and then when i name my 3 factories "factory_one", "factory_two", and "factory_three" the factory 3dprojectionctrl will attach to them.
so far i have the pop up GUI made and the ability to place the building obviously. Now i am trying to figure out how and when to display the popup window and have it target the object i just placed so that it will apply the name to that object only. also i was going to try to make it so if you selected another obbject befor applying the name it still applied it to the object you just made and not the object you currently have selected.
I was thinking once placed it (the object) could pass the object ID to the popup window and the popup window will at that point only work for that one object. once closed it clears the ID infor from the popup window.
Another idea is to have a button on the interface that allows you to rename buildings when you want by selecting them and hitting the rename button on the GUI. obvious problem being if you have more than one building selected it would probably crash or just not work.
so any thoughts or suggestions?
inspector.setName(InspectorNameEdit.getValue());The text input fild is obviously named InspectorNameEdit. Now my big question is will that work? am i using the right naming device (InspectorName) or should i be using "internalName" ?? I noticed in the world editor if i change the name in "internalName" the object still says 1773:(null) but if i change the name in InspectorName it changes to 1773:factory. Thats why i assumed i should use InspectorName.
Just so you know i want to do this so i can place a building, name it, then have the Gui3DprojectionCrtl attach to it based on its name. Exaple is having a gui3DProjectionCtrl for anything starting with "factory_" and then when i name my 3 factories "factory_one", "factory_two", and "factory_three" the factory 3dprojectionctrl will attach to them.
so far i have the pop up GUI made and the ability to place the building obviously. Now i am trying to figure out how and when to display the popup window and have it target the object i just placed so that it will apply the name to that object only. also i was going to try to make it so if you selected another obbject befor applying the name it still applied it to the object you just made and not the object you currently have selected.
I was thinking once placed it (the object) could pass the object ID to the popup window and the popup window will at that point only work for that one object. once closed it clears the ID infor from the popup window.
Another idea is to have a button on the interface that allows you to rename buildings when you want by selecting them and hitting the rename button on the GUI. obvious problem being if you have more than one building selected it would probably crash or just not work.
so any thoughts or suggestions?
About the author
#2
If you're talking about renaming objects selected using the RTS kit's selection rings, I believe the selected objects are held in a SimSet somewhere. You could just walk through that SimSet and call "%obj.setName(%newName);" and that would set the SimObject name.
Multiple selections shouldn't be a problem...if you don't want to handle that case, just call getCount() on the SimSet. You can test if it returns 1 and just ignore the action if it doesn't.
Actually, one complication is that there are *two* selection SimSets. One for the client-side, and one for the server-side. The RTS kit maintains both of them, and they contain different object IDs (one for the client objs & one for server objects, obviously). So you'd need to pick the one you want.
03/06/2008 (12:55 am)
Is this feature you're talking about a programming aid, like the world editor, or is it a feature in a game? Because if it's the latter, you wouldn't want to give a player that much power, i.e. the ability set SimObject names... he could easily crash the game by using a name that was already in-use.If you're talking about renaming objects selected using the RTS kit's selection rings, I believe the selected objects are held in a SimSet somewhere. You could just walk through that SimSet and call "%obj.setName(%newName);" and that would set the SimObject name.
Multiple selections shouldn't be a problem...if you don't want to handle that case, just call getCount() on the SimSet. You can test if it returns 1 and just ignore the action if it doesn't.
Actually, one complication is that there are *two* selection SimSets. One for the client-side, and one for the server-side. The RTS kit maintains both of them, and they contain different object IDs (one for the client objs & one for server objects, obviously). So you'd need to pick the one you want.
Torque Owner Zergcow