added controller number to event scripts parameter 1

Sun, 28 Oct 2012 20:09:28 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sun, 28 Oct 2012 20:09:28 +0100
changeset 112
fee43a74bed6
parent 111
7e9a451870ed
child 113
b2d91fd5d926

added controller number to event scripts parameter 1

slotUI/SlotCli.py file | annotate | diff | comparison | revisions
--- a/slotUI/SlotCli.py	Sun Oct 28 20:05:16 2012 +0100
+++ b/slotUI/SlotCli.py	Sun Oct 28 20:09:28 2012 +0100
@@ -54,9 +54,9 @@
         #os.spawnlp(os.P_NOWAIT, "/usr/bin/mpg123", "mpg123", SOUNDS[what])
         #Popen(["/usr/bin/mpg123", SOUNDS[what]]).pid
 
-def trigger_event(what):
+def trigger_event(what, slot = 0):
     trigger_sound(what)
-    Popen(["/bin/sh", os.path.abspath(EVENTPREFIX + what)])
+    Popen(["/bin/sh", os.path.abspath(EVENTPREFIX + what), str(slot)])
 
 class SlotServer(threading.Thread):
     def __init__(self, blackbox):
@@ -427,13 +427,13 @@
                         if (self.slot[slot]["best"] > t) or (self.slot[slot]["best"] == 0):
                             self.slot[slot]["best"] = t
                         if self.bestlap > t:
-                            trigger_event("lap_record")
+                            trigger_event("lap_record", slot + 1)
                             self.bestlap = t
 
                         self.slot[slot]["status"] = "IN-RACE"
                         if (self.slot[slot]["laps_last"] != l) and (l == self.laplimit):
                             # we have lap limit reached!
-                            trigger_event("win")
+                            trigger_event("win", slot + 1)
                             self.raceactive = False
                             self.slot[slot]["status"] = "WINNER!"
                             self.box.query("+") # stop race
@@ -452,12 +452,12 @@
                             if (self.slot[slot]["fuel_last"] == 16) and (f == 15):
                                 # 15 percent fuel, set speed limit for car to 8
                                 # warning sound
-                                trigger_event("fuel_warning1")
+                                trigger_event("fuel_warning1", slot + 1)
                                 cli.box.speedlimit(slot, 8)
                             if (self.slot[slot]["fuel_last"] == 6) and (f == 5):
                                 # 5 percent, set speed limit for car to 6
                                 # warning sound
-                                trigger_event("fuel_warning2")
+                                trigger_event("fuel_warning2", slot + 1)
                                 cli.box.speedlimit(slot, 6)
                             if (self.slot[slot]["fuel_last"] == 1) and (f == 0):
                                 # fuel empty
@@ -466,7 +466,7 @@
                             if (self.slot[slot]["fuel_last"] < f) and (f >= 11) and (f < 20):
                                 cli.box.speedlimit(slot, 15)
                             if (self.slot[slot]["fuel_last"] < f) and (f == 100):
-                                trigger_event("fuel_full")
+                                trigger_event("fuel_full", slot + 1)
                         self.render_slots()
 
                     if rx[:1] == "~":
@@ -487,10 +487,10 @@
                             # pitlane sent something
                             if (status == 5):
                                 self.slot[slot]["status"] = "PITLANE"
-                                trigger_event("pitlane_enter")
+                                trigger_event("pitlane_enter", slot + 1)
                             if (status == 7):
                                 self.slot[slot]["status"] = "IN-RACE"
-                                trigger_event("pitlane_exit")
+                                trigger_event("pitlane_exit", slot + 1)
 
                         self.render_slots()
 

mercurial