 # Time split error

This is the time translation system in my project. Currently i have a little problem with this. As you can see the number turn after 108.84 to 10.8 instead of 110.84 and so it goes with next values…

108.84 equals to an integer value 10884, which is saved in one external text file to define the timing there an arrow should be spawned.

btime is the integer value 10884
(at 1:39:84, the minute is already 60 seconds so its calculated to gether to 108 seconds and 84 milisecs)

bcent is the 84
bsec is the 08
bmint should be the 1

Is there a way to stabilze it. If you do not understand my question just make questions…
I cant show you the whole code since its written by Pohjan and its really long. The other parts of the code dont concern this timing splitting function.

Thanks in advance

``````
#first parse BBBBCC to centseconds
bcent=btime%100
bsec=int(btime/100)%100
bmin=int(btime/1000) #&lt;&lt;&lt;&lt; how should i format bmin?

bmilli=bmin+bsec+(bcent/100)
return bmilli
``````

I’m afraid that your question isn’t phrased well enough to understand the problem. could you upload some sample data and what you would like the result to be?

Are you trying to convert milliseconds into seconds?

Btw.
as far as I remember you can divide fractionless with // rather than /.

BBBBCC stand for what?
BBBB is the seconds and the CC centiseconds?

Is the integer fixed lenght?
Meanign BB.C, BBBBB. or B.CC cant happen?
Are the first four numbers a seconds and the last two the centiseconds?

sentisecond to millis
1 centisecond = 10 milliseconds
var = 10884
milliSec = (var/100.0)*1000.0

sentisec to seconds
var = 10884
sec = (var/100.0)

thanks guys

the script was not written by me so i could not really understand how its working… but these are parts that strongly relate to the function. The creator of the script define BBBBCC just as a name for the def class

``````
def bbbbcc_to_millis(btime):

#first parse BBBBCC to centseconds
bcent=btime%100
bsec=int(btime/100)%100
#bmin=int(btime/10000)

bmilli=bsec+(bcent/100)
return bmilli

``````

the script uses ‘import time’. from that we get a new value called deltime

``````

dtime=(time.time()-vm['start'])*100  #secs*60=fps
deltime=dtime+(vm['delay'])
anitime=dtime+(vm['dancerdelay'])
camtime=dtime

``````

this is the condition to send the message by comparing deltime and btime…

``````
if (deltime/100.0)&gt;btime:
print ("Beat at:",int(dtime),int(deltime),bkeys)
vm['listcount']+=1
bge.logic.sendMessage(bkeys)           #Still send message too (If still use them)
vm['note']=bkeys

``````

thanks everyone, i solved the problem by this:

``````
def bbbbcc_to_millis(btime):

#first parse BBBBCC to centseconds
bcent=btime%100
bsec=int(btime/100)%100
bmin=int(btime/10000)

bmilli=(bmin*100)+bsec+(bcent/100)
print (bmilli)
return bmilli

``````

the whole formula makes not much sense.

I think you can simply divide btime by 100

``````
def bbbbcc_to_millis(btime):
return btime/100

``````

the name let me assume that btime is given in 1s/100000. Usually 1s/1000 (=milli seconds) is assumed as the smallest time value. Therefore I do not understand why it should get fractions.

The formula itself let me guess that btime is given in 1s/100. The result would be in seconds (with fractions). In my eyes that makes more sense. But it makes the function name incorrect too.

thanks monster

i try to see if its possible to replace that in the script. the script has about 7000 characters and so many sub functions in it. only Pohjan knows how to fix it best