The online racing simulator
Can you please send me the file threw pm as the page isn't working.
Cheers
#27 - CSF
Why do you require them?
I just want to try it out looks awsome
To use the program you would need the WolleT/Poo fyi / Moe Tracker. Whether you have it or not I can't remember if I've written the tracker url to be configurable or not. It is likely it's not so you would not be able to use it for anything. I made it specifically for gtal, so I don't really see any use for it for anything else

However, if you read the post above yours you will see THIS LINK to the F1 overlay thing which is in fact what we used in GTAL last time round - I just had written a modified version to pull the results directly from the tracker.

Also, if someone would like I would be quite happy to share the source code for this. It's quite easily readable and modifiable python code*.

* Python is easily readable. The code might not necessarily be so, since often even I can't understand what I have written a few weeks earlier.
OK, thanks for that. Could I please have a look at the code. I have been working with python for about 2-3 years now.
Cheers
Okay, a few notes though: I've been a bit of an idiot apparently and used a lot of global variables. Packet handling things, connection establishment and so on are stolen from an example posted by DarkTimes.

A few variable names are annoyingly in Finnish.



#####################################################
## First things first.
##
## 17.12.2010 THy
##
## This program is not copyrighted.
## In stead I will merely eat your heart if you steal it.
## - Timo Hynninen 2010 timo.hynninen at&t lut.fi
##
##Lets import stuff and define ports

import pyinsim
import urllib
import threading
import codecs

end = False
teamlist = []
track = "Fern Bay Black"
weather = "Clear Day, No Wind"


print("Input target IP please: ")
ip = raw_input()
print("Input target port. Use 32300 unless you hae a different on for TV director!: ")
port = raw_input()
print("Input commentator man's name:")
commentatorman = raw_input()
##print("Input URL for position data (can be txt, xml, html etc):")
##url = raw_input()
print
print("There is an admin password field too but I can't think of any use for it \nI was probably drunk whilst making this program")
##print("Anyway, please input your name. If you're not the commentator, don't type \nyour name but the commentators.\nBecause we don't care about your name you half wit:")
##commentator = raw_input()

print



########################################
def insim_multiplayer(insim, rst):
global track
global weather
global wind
trackcode = rst.Track

if trackcode == "AS6R":
track = "Aston GT Rev"
elif trackcode == "AS6":
track = "Aston GT"
elif trackcode == "SO4R":
track = "South City Long Rev"
elif trackcode == "KY3":
track = "Kyoto GP Long"
elif trackcode == "BL1":
track = "Blackwood GP"
else:
track = trackcode
weathercode = rst.Weather
if weathercode == 0:
weather = "Clear Day"
elif weathercode == 1:
weather = "Cloudy Afternoon"
elif weathercode == 2:
weather = "Cloudy Sunset"
else:
weather = "Lovely"
windcode = rst.Wind
if windcode == 0:
wind = "No wind"
elif windcode == 1:
wind = "Weak wind"
elif windcode == 2:
wind = "Strong wind"


#########################################

class team:
number = 0
name = ""
drivers = ""

#############################################

def run_classification():
print_classification()
if not end:
threading.Timer(5.0, run_classification).start()


#####################################
## lets define the button generator
def kirjota():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=68,
BStyle=pyinsim.ISB_DARK | 5,
T=175,
L=68,
W=130,
H=10,
Text=teksti)

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=69,
BStyle=pyinsim.ISB_DARK | 5,
T=175,
L=48,
W=20,
H=10,
Text="Race Control:")
print

def commentary():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=71,
BStyle=pyinsim.ISB_LIGHT | 2,
T=5,
L=140,
W=45,
H=10,
Text=teksti)

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=70,
BStyle=pyinsim.ISB_LIGHT | 3,
T=5,
L=110,
W=30,
H=10,
Text="Commentary box:")

def commentator():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=70,
BStyle=pyinsim.ISB_LIGHT | 3,
T=5,
L=110,
W=30,
H=10,
Text="Your commentator:")

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=71,
BStyle=pyinsim.ISB_LIGHT | 2,
T=5,
L=140,
W=45,
H=10,
Text=teksti)
print

def trackinfo():
global track
global weather
global wind

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=61,
BStyle=pyinsim.ISB_LIGHT | 3,
T=17,
L=128,
W=12,
H=9,
Text="Track")

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=62,
BStyle=pyinsim.ISB_LIGHT | 4,
T=17,
L=140,
W=45,
H=9,
Text=track)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=63,
BStyle=pyinsim.ISB_LIGHT | 4,
T=26,
L=140,
W=45,
H=9,
Text=weather)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=64,
BStyle=pyinsim.ISB_LIGHT | 4,
T=35,
L=140,
W=45,
H=9,
Text=wind)
print


#######################################
##### This is how we get rid of stuff!
def clear():
insim.send(pyinsim.ISP_BFN, ClickID=61)
insim.send(pyinsim.ISP_BFN, ClickID=62)
insim.send(pyinsim.ISP_BFN, ClickID=63)
insim.send(pyinsim.ISP_BFN, ClickID=64)
insim.send(pyinsim.ISP_BFN, ClickID=65)
insim.send(pyinsim.ISP_BFN, ClickID=66)
insim.send(pyinsim.ISP_BFN, ClickID=67)
insim.send(pyinsim.ISP_BFN, ClickID=68)
insim.send(pyinsim.ISP_BFN, ClickID=69)
insim.send(pyinsim.ISP_BFN, ClickID=70)
insim.send(pyinsim.ISP_BFN, ClickID=71)

def clear_classification():
for i in range(1, 61):
insim.send(pyinsim.ISP_BFN, ClickID=i)
print



##################################
## Classification print code ##
def print_classification():

try:
classification(29)

except IndexError:
print("BTW:")
print("Boothy is an arse and changed the tracker. Yell at him for that")

try:
tiedosto = urllib.urlopen("http://tracker.newdimensionracing.com", "r")
x = tiedosto.read().split("</dd>")
y = x[3].split("<dd>")
remaining = y[1]
tiedosto.close()
except IndexError:
remaining = "00:00:00 "

## aika
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=60,
BStyle=pyinsim.ISB_DARK | 0,
T=175,
L=1,
W=47,
H=8,
Text=remaining+"remaining")


def classification(number):
apu = 5
tiedosto = urllib.urlopen("http://tracker.newdimensionracing.com/", "r")
x = tiedosto.read().split("<td class='teamName'>")
for i in range (1, number):

p = x[i].split("</td>")
p = p[0]

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=i,
BStyle=pyinsim.ISB_LIGHT | 1,
T=apu,
L=1,
W=6,
H=6,
Text=str(i))

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=30+i,
BStyle=pyinsim.ISB_LIGHT | 2,
T=apu,
L=7,
W=33,
H=6,
Text=p)
apu = apu+6
tiedosto.close()

###############################
# Team info
def print_team_info():
for entry in teamlist:
print entry.number, entry.name, ";",
print
print "Which team do you want (input number)? Non-existant number to exit:"
valinta = raw_input()
try:
valinta = int(valinta)
for entry in teamlist:
if valinta == entry.number:
teksti1 = str(entry.number)
teksti2 = str(entry.name)
teksti3 = str(entry.drivers)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=65,
BStyle=pyinsim.ISB_LIGHT | 6,
T=155,
L=68,
W=12,
H=10,
Text=teksti1)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=66,
BStyle=pyinsim.ISB_DARK | 5,
T=155,
L=68,
W=80,
H=10,
Text=teksti2)

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=67,
BStyle=pyinsim.ISB_DARK | 5,
T=165,
L=68,
W=130,
H=10,
Text=teksti3)

break
except:
print "something went wrong again :|"



################################
## Team info handler here:

teamlist = []
tiedosto = codecs.open("nimet.timofile", "r", "utf-8")
tiedosto.readline()
while True:
rivi = tiedosto.readline()
if len(rivi) == 0:
break
else:
x = rivi.split(';')
y = team()
y.number = int(x[0][0:2])
y.name = x[0][2:]
y.drivers = x[1][:-1]
teamlist.append(y)


#################################

insim = pyinsim.insim(ip, int(port), Admin='', IName='TheMasterbator', Flags=pyinsim.ISF_LOCAL)
insim.bind(pyinsim.ISP_RST, insim_multiplayer)
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_RST)
pyinsim.run(background=True)

##Now the menu.


while True:
print("\nChoose what ya wanna do mother****er!")
print("1) Race control message")
print('2) Print "Voice of [commentators name]".')
print('3) Print "Voice of [someone else]".')
print("4) Clear everything but classification")
print("5) Print classification.")
print("6) Clear classification.")
print("7) Print track info.")
print("8) Print team info")
print("0) QUIT. Don't choose this one. SRSLY!")
print
print("Choose what you want to do: ")
valinta = raw_input()
try:
valinta = int(valinta)
except:
print("You've typed text instead of a number you halfwitted babboon!")
if valinta == 2:
teksti = commentatorman
commentator()

elif valinta == 5:
end = False
threading.Timer(0.1, run_classification).start()


elif valinta == 1:
print "Race control message:"
teksti = raw_input()
kirjota()

elif valinta == 4:
clear()

elif valinta == 6:
end = True
threading.Timer(5.0, clear_classification).start()
threading.Timer(11.0, clear_classification).start()

elif valinta == 7:
trackinfo()

elif valinta == 8:
print_team_info()

elif valinta == 3:
print "Write co-commentator's / interviewee's name:"
teksti = raw_input()
commentary()

elif valinta == 0:
break
## elif valinta == 11:
## threading.Timer(2.0, run_aika).start()
## elif valinta >4:
## print("No, you don't get to do that.")
## print
elif valinta < 0:
print("No, you don't get to do that.")
print
else:
print


################################
## Apparently this doesn't work. No matter, I'll do it anyway :)
insim.close()
print("You're a faggot. And you've just closed this program")


######################################
## EOF



Cheers for that.
A few question.
1. Do I need any other programs eg pyinsim act.?
2. How do I connect it to LFS?
3. I have Python but do I just coppie that to the new window?
Kind Regards,
J.Provost :P
Reading often helps

Quote from Jonathon.provost :Cheers for that.
A few question.
1. Do I need any other programs eg pyinsim act.?


[COLOR="Red"]import pyinsim[/COLOR]

You just might...

Quote :

2. How do I connect it to LFS?

The same way every other insim program works. Do a /insim XXXXX in lfs, then run the program.


print("Input target IP please: ")
ip = raw_input()
print("Input target port. Use 32300 unless you have a different on for TV director!: ")
port = raw_input()

Quote :
3. I have Python but do I just coppie that to the new window?

You'll need python 2.7. After installing get the latest pyinsim from here.

Then just open IDLE (Python IDE), open a new file (ctrl+n), c/p the code in, press F5 to run it.

Note that this bit:

## Team info handler here:

teamlist = []
tiedosto = codecs.open("nimet.timofile", "r", "utf-8")
tiedosto.readline()
while True:
rivi = tiedosto.readline()
if len(rivi) == 0:
break
else:
x = rivi.split(';')
y = team()
y.number = int(x[0][0:2])
y.name = x[0][2:]
y.drivers = x[1][:-1]
teamlist.append(y)

will cause infinite IOError unless you comment it out ( highlight the section, Edit->comment out region).

...
As I said yesterday evening it'll probably do no good to try and use it for something as it is. It's not even a good programming example, I wrote the most bits last year about halfway through a course called "programming fundamentals" so you can imagine the quality.
When Installing pyinsim I don't know what this means
" Unzip the archive on your computer and locate the folder contents using your computers command line tool. To install the library run the command python setup.py install."
Please help
download the pyinsim.2.0.4.win32.zip file in stead, it has an installer wizard that does everything automatically.
I have 64bit

" To install on a different OS, or with different installation options (64 bit Windows etc..) you must use the source distribution"


EDIT: Dosn't matter i downloaded the 32 bit python cheers

AMAZING system mate.
I just wanted to ask if we could use it for our events
Cheers

One thing where do I put the teams that I want to show and How

And when I put the classifications up its Chinese or somin is that to do with the teams?
Quote from Jonathon.provost :I have 64bit

" To install on a different OS, or with different installation options (64 bit Windows etc..) you must use the source distribution"

Normally the files have instructions in them (even the .py file).

Quote :
AMAZING system mate.
I just wanted to ask if we could use it for our events
Cheers

You can, as you can see I've released the source with a "do whatever the **** you want"-license.

Quote :
One thing where do I put the teams that I want to show and How

And when I put the classifications up its Chinese or somin is that to do with the teams?

It's not Chinese

The buttons in LFS work quite uniquely. What you are seeing is too many letters to actually fit in the button, therefore they are just very cramped there. Basically what has happened is boothy was a complete arse and made changes to the tracker. You would have to look up the part that handles reading the actual html code off the tracker website and adjust it to work with the new tracker layout. I might actually do that myself too and post it here, after all I use that same function in other programs so it only needs to be written once.

As I explained it's only a tool to read the Moe Tracker. To be able to use it you need to run the tracker as well. Or alternatively you can figure out how to make it work based only on lfs positions, there is a fine example of how to do that in the pyinsim thread. You can input the position and gap data yourself by modifying the button generation bit - the module called classification: (I changed the variable names to be more distinctive here, don't be scared of that, it's still the same piece of code)


def classification(number):
bookmark = 5
tracker_website = urllib.urlopen("http://tracker.newdimensionracing.com/", "r")
tracker_data = tracker_website.read().split("<td class='teamName'>") # split the whole string into an array
for i in range (1, number):

p = tracker_data[i].split("</td>") # split each member of the array again to get rid of unnecessary html code
p = p[0] # this is now the actual team name

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=i,
BStyle=pyinsim.ISB_LIGHT | 1,
T=bookmark,
L=1,
W=6,
H=6,
Text=str(i))

insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=30+i,
BStyle=pyinsim.ISB_LIGHT | 2,
T=bookmark,
L=7,
W=33,
H=6,
Text=p)
bookmark = bookmark+6
tracker_website.close()


If you don't actually understand what this bit does there is very little I can do to help. You could of course comment out the button parts all together and just print all the strings that are being handled, perhaps that'll give a better impression of what is being done. That said, to utilise any of this you should be able to understand basic list operations plus for and if clauses. That's about all there is.
The tracker is currently showing qualifying results so looking for a table cell with the class "teamName" would actually give you:<img src="/flags/fin.gif" alt="" title="FIN" height="12" width="18"><span title="maunokasa">Jarno Lehikoinen</span> - perhaps try the MoE tracker as it has a race result in it.
-
(Jonathon.provost) DELETED by hyntty : le :|
-
(Jonathon.provost) DELETED by hyntty : le :|
-
(hyntty) DELETED by hyntty : le :|
-
(Jonathon.provost) DELETED by hyntty : le :|
-
(hyntty) DELETED by hyntty : le :|
-
(Jonathon.provost) DELETED by hyntty : le :|
-
(hyntty) DELETED by hyntty : le :|
bumpage
BUMP LE ****!!

I've no idea if anyone cares anymore but I've been playing with stuff again. (not that stuff, that other, less disgusting stuff.)

Quote from hyntty :
making a simple F1 (or more like motogp) style real-time timing

So here's a shitty video of it (I should have used screencapping software I know :| ) http://dl.dropbox.com/u/16059823/VIDEO0007.3gp
Quote from hyntty :BUMP LE ****!!

I've no idea if anyone cares anymore but I've been playing with stuff again. (not that stuff, that other, less disgusting stuff.)



So here's a shitty video of it (I should have used screencapping software I know :| ) http://dl.dropbox.com/u/16059823/VIDEO0007.3gp

Great stuff... though... LFS scores a 33.65, your program a 30.9?

http://code.google.com/p/irtvo/

I know you're not known to iRacing, but since it is open source, and since it works really great with iRacing (ok, sometimes more sometimes less well), maybe you see something in the program to combine it with your stuff... It could be the ultimate Masterbator.
-
(hyntty) DELETED by hyntty
Right, I've reconfigured the timer to actually time the lap (previously it didn't). Shit print screen previews attached. The timing window is of different size in the pics because it scales itself dynamically according to the string lengths of player name and time.
Attached images
Untitled.png
Untitled2.png
2

FGED GREDG RDFGDR GSFDG