Skip to content

Commit

Permalink
2 or 3 value position check
Browse files Browse the repository at this point in the history
  • Loading branch information
Luomu committed Nov 21, 2010
1 parent 9ae96d8 commit d2157e1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions parse
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,17 @@ def findSimpleValue(line):
def createToVehicle(create):
#we can expect the statement to have a certain structure
#_this = createVehicle ["Fort_Barracks_USMC", [1224.7141, 1484.4183, 1.1444092e-005], [], 0, "CAN_COLLIDE"];
vehi = Vehicle("Unnamed")
arr = create[create.find("[")+1:create.rfind("];")].split(",")
#or
#_this = createVehicle ["RoadBarrier_long", [4234.3018, 3948.8118], [], 0, "CAN_COLLIDE"];
vehi = Vehicle()
create = create[create.find("[")+1:create.rfind("];")]
arr = create.split(",")
#from this array we can just grab what we need
vehi.className.value = arr[0].replace("\"","")
#in vehicles pos is overridden by setPos but not for units
#todo: this is silly
x = arr[1].strip()[1:]
z = arr[2].strip()
y = arr[3].strip()[:-1]
vehi.position.value = "{0}, {1}, {2}".format(x, y, z)

#in vehicles pos is overridden by setPos anyway
position = create[create.find("[")+1:create.find("]")]
vehi.position.value = position
return vehi

def createToUnit(create):
Expand Down Expand Up @@ -304,7 +305,10 @@ class SqmDocument:
elif "setPos" in line:
#notice y,z swap
pos = line[line.rfind("[")+1:line.rfind("]")].split(",")
veh.position.value = "{0}, {1}, {2}".format(pos[0],pos[2],pos[1])
x = pos[0]
y = pos[1]
z = pos[2] if len(pos) > 2 else 0
veh.position.value = "{0}, {1}, {2}".format(x, z, y)
elif "setUnitAbility" in line:
veh.skill.value = line[line.rfind(" ")+1:line.rfind(";")]
elif "selectPlayer" in line:
Expand Down

0 comments on commit d2157e1

Please sign in to comment.