BVM Questions

Blitz3D Forums/Blitz3D Programming/BVM Questions

How do I pass a variable to the UpdateEntity() function? (The entity!)
I have to admit this explanation really lacks in the "basics" part of the docs (it's explained in the tutorial though). The recent questions I was asked gave me good hints about what needs improvments in the docs, and it *will* be improved.

Passing parameters is done by pushing them on the context stack. For that use BVM_PushInt,BVM_PushFloat and BVM_PushString.
By example say your function is:
Function SomeFunc$(param1%, param2#)
...
End Function

All you have to do in your main program is to push the parameters, invoke the function, then pop the return value.
BVM_PushInt(20) ; the value for param1 (it's an integer, so use BVM_PushInt)
BVM_PushFloat(1.23) ; the value for param2 (it's a float, so use BVM_PushFloat)
BVM_SelectEntryPoint(hEP_SomeFunc)
BVM_Invoke_MYCOMMANDSET()
returnValue$ = BVM_PopString() ; the return value (it's a string, so use BVM_PopString). 
    ; If we don't need the return value than we just do "BVM_PopString()" and don't 
    ; store the result anywhere (but popping it would *still* be required).


Can I have more than one function called "UpdateEntity" in the same context, or do I have to call each entity's update routine a different name?
Each script is a separate program, and thus the names you use in one script doesn't interfer in the other ones. Using the same function name in different scripts is actually a common and good usage, if you're planning to use one script per entity.
So you can have each script have its very own "UpdateEntity" function, no problem at all.

Is there any inherit overhead in calling a function? Should I call one UpdateMonsters() function, or is it okay to call each UpdateMonster() function individually?
I don't think you can find any significant speed difference between both solutions, so choose the one that best fits your needs.