I've got some simple Blitz3d code that I want to import into BMAX. I have imported the BB project into Bmax but it don't work. The error I get is "Compile Error:Identifier 'HandleFromObject' not found"
I suspect the imported code is incorrect and that I should be using handles and objects in some other way... But how??
Here is the B3D code
Type timer
Field Duration
Field Value
Field LastMs
End Type
; **************************************************
Function CreateTimers(Duration)
t.timer = New timer
t\Duration = Duration
t\Value = Duration
t\LastMs = MilliSecs()
Return Handle(t)
End Function
; **************************************************
Function DeleteTimer(timer)
Local t.timer = Object.timer(timer)
Delete t
End Function
; **************************************************
Function UpdateTimers()
Now = MilliSecs()
For t.timer = Each timer
t\Value = t\Value - (Now - t\LastMs)
t\LastMs = Now
Next
End Function
; **************************************************
Function ResetTimer(timer,value = 0)
Local t.timer = Object.timer(timer)
If value = 0 Then
t\Value = t\Duration
Else
t\Value = Value
EndIf
End Function
; **************************************************
Function GetTimerValue(timer)
Local t.timer = Object.timer(timer)
Return t\value
End Function
Here is the bMAX imported code
Import "bbtype.bmx"
Import "bbvkey.bmx"
Global timer_list:TList=New TList
Type bbtimer Extends TBBType
Method New()
Add(timer_list)
End Method
Method After:bbtimer()
Local t:TLink
t=link.NextLink()
If t Return bbtimer(t.Value())
End Method
Method Before:bbtimer()
Local t:TLink
t=link.PrevLink()
If t Return bbtimer(t.Value())
End Method
Field Duration
Field Value
Field LastMs
End Type
' **************************************************
Function CreateTimers(Duration)
t:bbtimer = New bbtimer
t.Duration = Duration
t.Value = Duration
t.LastMs = MilliSecs()
Return HandleFromObject(t)
End Function
' **************************************************
Function DeleteTimer(timer)
Local t:bbtimer = bbtimer(HandleToObject(timer))
t.Remove()
End Function
' **************************************************
Function UpdateTimers()
Now = MilliSecs()
For t:bbtimer = EachIn timer_list
t.Value = t.Value - (Now - t.LastMs)
t.LastMs = Now
Next
End Function
' **************************************************
Function ResetTimer(timer,value = 0)
Local t:bbtimer = bbtimer(HandleToObject(timer))
If value = 0 Then
t.Value = t.Duration
Else
t.Value = Value
EndIf
End Function
' **************************************************
Function GetTimerValue(timer)
Local t:bbtimer = bbtimer(HandleToObject(timer))
Return t.value
End Function
|