Syntax error ;

Monkey Forums/Monkey Programming/Syntax error ;

ErikT(Posted 2011) [#1]
Hello, I'm trying to convert Peter J Rigby's collision mod for blitzmax to monkey code and just hit my first snag:

		r.aa = aa * m.aa + ab * m.ba;r.ab = aa * m.ab + ab * m.bb


Monkey chokes on the semicolon and what I'm wondering about is what is the semicolon used for in bmax syntax? I never used or saw it before and haven't been able to track down any references to it so far.


anawiki(Posted 2011) [#2]
; is used to separate commands. In Monkey replace it with Enter or space (Enter preferred).


ErikT(Posted 2011) [#3]
Nice, thanks :)

EDIT: Err, what about the ^ in this line of code?

While area>texwidth^2


It seems to be used to denote power of two. I suck at math though and don't quite understand what power of x is supposed to do in the first place. Is there any easy replacement for this in monkey syntax?


therevills(Posted 2011) [#4]
Try

While area>Pow(texwidth,2)



ErikT(Posted 2011) [#5]
Yes, it works! Thanks :D


ErikT(Posted 2011) [#6]
Okay, another couple of questions.

Is this blitzmax code...
Field map:tlQuadTreeNode[,]

... the equivalent of this in monkey?
Field map:tlQuadTreeNode[][]


The compiler also throws a ", expected" error on this line because of callback it seems. Any ideas how to fix?

Method ForEachObjectInArea(x:Float, y:Float, w:Float, h:Float, Data:Object, callback:Int(ReturnedObject:Object, Data:Object), Layer:Int = tlLAYER_ALL)



ErikT(Posted 2011) [#7]
And another. By commenting out a couple of trouble areas I've gotten the code to compile. But whenever I try to call the below function I get an error message in the semanting part of compiling saying that 'module tlBox not found'.

#rem
	bbdoc: Create a New #tlBox
	returns: New #tlBox
	about: Creates a New Bounding box that you can use For collision checking And adding To a #tlQuadTree. Use layer To specify a particular layer
	To place the box on so that you can more easily organise your collisions. You use tlLAYER_1, tlLAYER_2..And so on up To tlLAYER_32, Or tlLAYER_ALL
	To place the boundary on all layers.
#End
Function CreateBox:tlBox(x:Float, y:Float, w:Float, h:Float, layer:Int = tlLAYER_1)
	Return New tlBox.Create(x, y, w, h, layer)
End Function


The code compiles and runs fine in blitzmax. I've done all the proper imports and the class for tlBox is definitely in there. What the hell...


therevills(Posted 2011) [#8]
With the ForEachObjectInArea method, callbacks are not supported in Monkey and with the CreateBox I think the compiler is trying to find a module called tlBox - change it to New tlBox(x, y, w, h, layer) and create the constructor in tlBox which has the nearly the same code as the Create method.


ErikT(Posted 2011) [#9]
Hmmm... I tried pasting all the code from the Create method into the CreateBox function, and then to create a local tlBox within that gets returned instead. Now the same error message pops up within the tlBox class itself, again for the Create method:

	Field handle:tlVector2 = New tlVector2.Create(0, 0)


Oh dear, hope this method isn't utilised too much :P