Jump to content

Vehicle individuality >_>


Deddalt

Recommended Posts

Posted

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?

Posted

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 :P)

Posted

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" /> 

Posted
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" /> 

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..?

Posted

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.

Posted

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 
  

Posted
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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...