I’ve taken the plunge, and started to try Python. My first small task was to get a script to read the speed of an object and output it to a property. I found and adapted one from the archives, but also thought it would be nice to have an automatic kph/mph string on the end of the speed readout. I have tried using str() but I get ‘xspeed kph’ rather than ‘123 kph’- here is what I have so far:
I cant believe it was that simple, I feel a bit of an idiot!
I’m a bit confused as to what is going on though- am I isolating the integer from the string (so Python knows they are different types rather than making them all strings)?
shouldn’t it be:
object[‘text’] = str(xValue) + str(kph)
assuming you want to set the words “kph” from a property.
Of course that method works fine if not.
Both ways work well, but I have a minor problem-the velocity is now being read in a float style value (like 5.0032434234kph rather than 5kph). How would I change that to an integer (i.e whole numbers)?
Like I said, 2.5 tutorials are quite rare- and its really good having every line explained in detail in a game context. As a suggestion, it may be useful to have a small tutorial on converting old 2.49b scripts to 2.5x (or cover the basics). Either that or have a vault of useful mall scripts that people can pick apart.