BlitzScript3D

Blitz3D Forums/Blitz3D Programming/BlitzScript3D

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.

I'm doubting that BlitzScript3d could access my types that are hardcoded in my engine. So i'm probably still have to create a wrapper for those correct?

SortOf, considering the BlitzScript3D Engine is compiled with your Blitz App. You will have to 'hardcode' access to them in BlitzScript3D Compiler and VM to expose them within scripts. To do this, you will have to:

1) Add a "Command_Label" and Command Index to the bscvmCompilerCallIndex. This allows the Compiler to recognize the 'command' within a script as a valid function.

2) Add a Command Call to your function in the bscvmThreadCallIndex to be executed by the VM. This tells the VM what command to execute when processing the compiled script.

Thats it. These functions are just two big select case structures. They provide a lot of flexibility and they're fast. You can get a greater idea if you look at the code modules, but, I'll explain here as well.
bscvmCompiler.bb:  Function bscvmCompilerCallIndex

Purpose: Compiler Call Selector. Makes Commands Calls recognizable by compiler from scripts.
The Return values match the Command Index# called in the bscvmThreadCallIndex. You can easily
 add new commands to the scripting engine by adding a case here and the bscvmThreadCallIndex.

Add a New Command:
	Case "your_command_label" Return Index#
		
Parameters: bscvmCompiler Object

Return: bscvmThreadCallIndex#


bscvmThread.bb: Function bscvmThreadCallIndex 

Purpose: VirtualMachine Call Selector. Called by bscvmThreadProcess to executes Command calls.
Parameter values are stored in the this\arg[0-15] and the Return value is stored in this\ax. 
The Select Case Values are matched to the command labels in the bscvmCompilerCallIndex. 
You can easily add new commands to the scripting engine by adding a case here and the 
bscvmCompilerCallIndex.

Add a Command w/ Arguments:		
	Case Index# Your_Function(this\arg[0])

Add a Command w/ Return Value:	
	Case Index# this\ax=Your_Function(this\arg[0]) 

Add a Command with no Arguments:
	Case Index# Your_Function()

Add a Command w/Return Value and no Arguments:
	Case Index# this\ax=Your_Function() 

Parameters: bscvmThread Object
Return: None.
The VM passes and returns string, float, and integer values with functions. If your functions work with types internally, you may have to use Object/Handle command to pass or return a specified type or use globals. I personally use a Array_Of_Types Indexing System. Anyhow, the two steps above is all that is needed to expose your 'hardcoded' functions, arrays, variables, etc within script.

I'm going to eventually append all the code modules into one file, so all you have to do is Include "BlitzScript3D.bb", BlitzScript3DStart() {initialize}, BlitzScript3DUpdate() {main loop}, and BlitzScript3DStop() {shutdown}.