Deddalt Posted August 14, 2008 Posted August 14, 2008 I want to make all of my vehicles in a .map, but I want to be able to handle them individually. Also, I want to have a /start and /stop command for turning vehicles on and off. What would be the shortest way to do this?
Lordy Posted August 14, 2008 Posted August 14, 2008 What do you mean by "handle them individually"? And for start/stop, you can destroy the elements when stop and reload the map at start I think (but don't trust me )
[UVA]Bart Posted August 14, 2008 Posted August 14, 2008 loop throught all the vehicles and give them a seperate id at the start of the map, or give them all a seperate id when they are created
Mr.Hankey Posted August 14, 2008 Posted August 14, 2008 for individuality just add an id attribute to the car's node so you can get the vehicle element directly by using getElementID e.g: <vehicle id="first" model="372" posX="0" posY="0" posZ="10" /> <vehicle id="2" model="372" posX="0" posY="3" posZ="10" />
Gamesnert Posted August 14, 2008 Posted August 14, 2008 for individuality just add an id attribute to the car's node so you can get the vehicle element directly by using getElementIDe.g: <vehicle id="first" model="372" posX="0" posY="0" posZ="10" /> <vehicle id="2" model="372" posX="0" posY="3" posZ="10" /> ID="1", ID="2" etc is most recommended by me. And when all of your vehicles have numeric ID's, you can easily loop through them with getElementByID and destroy them by command. Making them appear again is another story... But... Ehm... Store them in tables perhaps..?
Mr.Hankey Posted August 14, 2008 Posted August 14, 2008 it really doesnt matter if you use "first" "second", "1" "2" or "bluecheetah" and "redadmiral" string is string =)
Gamesnert Posted August 14, 2008 Posted August 14, 2008 Numbers are easier, you can make a table with all the number vehicles and they're easy to loop. You can do a for or a while loop that constantly reads out 1 ID higher, instead of that you have to type words. So words are more limited, a lot more vehicles are supported by numbers or words+numbers.
tma Posted August 14, 2008 Posted August 14, 2008 ID's as strings are pretty handy because they can be more descriptive (as in Mr. Hankey's examples) and they're just as easy to loop through: for index,value in pairs({["apples"] = 50,["pears"] = 99}) do outputChatBox(index .. " are " .. value .. "p guv'ner.") end
Gamesnert Posted August 14, 2008 Posted August 14, 2008 ID's as strings are pretty handy because they can be more descriptive (as in Mr. Hankey's examples) and they're just as easy to loop through: for index,value in pairs({["apples"] = 50,["pears"] = 99}) do outputChatBox(index .. " are " .. value .. "p guv'ner.") end I don't really see what's better with strings that tostring(number) or something... Oh well, do what's the best choise.
DiSaMe Posted August 15, 2008 Posted August 15, 2008 It's not necessary to use numbers for IDs. If it's really needed, it's already possible to loop through all elements, they have their own numerical IDs
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now