-- DEPENDENCY CODE local hext = { [0]="0",[1]="1",[2]="2",[3]="3",[4]="4",[5]="5",[6]="6",[7]="7",[8]="8",[9]="9",[10]="A",[11]="B",[12]="C",[13]="D",[14]="E",[15]="F"} local dect = { ["0"]=0,["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,["9"]=9,["A"]=10,["B"]=11,["C"]=12,["D"]=13,["E"]=14,["F"]=15} local function c(s,i) return dect[string.sub(s,i,i)] end local function dec(s) return (c(s,1)*4096 + c(s,2)*256 + c(s,3)*16 + c(s,4))-32768 end -- [...] function advtrains.decode_pos(pts) if not pts or not #pts==6 then return nil end local stry = string.sub(pts, 1,4) local strx = string.sub(pts, 5,8) local strz = string.sub(pts, 9,12) return vector.new(dec(strx), dec(stry), dec(strz)) end