Sendmessage

BlitzMax Forums/BlitzMax Beginners Area/Sendmessage

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Well, as instance, you could use the object to return the state of the object once the message has been processed.

Imagine this scenario:
Const NoChange:int = 0
Const DeleteShip:int = 1

Type GameEngine
    Field Ships:Tlist 
    ....
    ....
    Method UpdateShips()
        For S:Ship = eachin Ships
            Local Result:UpdateResult = UpdateResult(S.SendMessage("Update"))
            If Result.Status = DeleteShip then
                Ships.Remove(S)
            End If
        Next
    End Method
End Type

Type UpdateResult
    Field Status:Int=NoChange
End Type

Type Ship
    ...
    ...
    Method SendMessage:Object(Message:Object, Param:Object = Null)
        ....
        ....
        If Message = "Update" Then
            Local R:UpdateResult = New UpdateResult
            If ShipCollidedWithLaser then
                R.Status = DeleteShip
                Return R
            Else
                R.Status = NoChange
                Return R
            End If
        End If
    End Method
End Type


this is just a pseudo-code silly example of a possible usage for the sendmessage method