Any ways to switch .bb file inside the game?

Blitz3D Forums/Blitz3D Programming/Any ways to switch .bb file inside the game?

ChrML(Posted 2003) [#1]
Are there any ways to switch the .bb file ingame, without use of functions?
Like, if I could use files like this:

intro.bb
level1.bb
level2.bb
bonuslevel1.bb
endingscreen.bb
etc...

, so when I want to change level, it passes the globals, and loads level1.bb (so level1.bb keeps all loadingscripts for loading that level, and that level's mainloop). I won't use Function for that, because that has limitations. Any ideas?


GfK(Posted 2003) [#2]
No, because when you compile it, BB code doesn't 'exist' any more.

Read up on the Include command. That's one way.

Another way is to invent your own basic scripting language and store each level in a custom format which is loaded/parsed by the program when required.


ChrML(Posted 2003) [#3]
Oh, ok. I think I'll have one file called Game.bb, and then include all files in that.


ChrML(Posted 2003) [#4]
Hmm, I wouldn't say that the code is gone after compiling it. Open up the created exe file in a hex editor, and have a look at the almost bottom. I recognize my code there, in real letters :).


Codemonger(Posted 2003) [#5]
"I recognize my code there, in real letters"

Really ... I guess blitz is interpreted like VB or a scripting language as opposed to already compiled ... hmmm, I didn't know that.


GfK(Posted 2003) [#6]
Hmm, I wouldn't say that the code is gone after compiling it. Open up the created exe file in a hex editor, and have a look at the almost bottom. I recognize my code there, in real letters :).
There are recognisable names of variables, functions and constants, but it isn't Blitz code.
Really ... I guess blitz is interpreted like VB or a scripting language as opposed to already compiled ... hmmm, I didn't know that.
No - Blitz is a compiler not an interpreter.


LAB[au](Posted 2003) [#7]
someone did it! check blitz virtual machine from koriolis
http://koriolis.free.fr/bvm/


ChrML(Posted 2003) [#8]
It is a blitz code. They are in the same order as the commands in my code, and starts with f_, for function. The exe is an already compiled game, that runs the commands in the bottom of itself.

I suppose that virtual machine uses Blitz3D's compiler to compile it. Incase it doesn't, it's illegal.


LAB[au](Posted 2003) [#9]
From the website :

------------
"Blitz Virtual Machine" (BVM) is a virtual machine that can run code written in BlitzBasic. It ships with a compiler that compiles BlitzBasic source files into bytecode modules that can then be executed by the virtual machine. You can use it by loading and executing at runtime precompiled bytecode files (="modules"), or by compiling source file and executing the result at runtime, which basicly gives you an interpreter.

BVM's primary use is to add to your game a scripting system in which the script language is BlitzBasic itself.
It comes in the form of a userlib and blitz source files.
--------------


And for Illegal statement:

--------------
What is to prevent someone from writing a general BVM host program and giving it away for free. essentially giving away a free version of blitz3d ?
The licence explicitely forbid this malicious use of BVM. You can't use BVM to write a stand-alone commercial 3d or game engine. If you try to do, then it basicly means that you resell BlitzBasic itself, which BlitzResearch (and consequently myself) will of course not tolerate. If (and only if) you can find an arrangement with BlitzResearch to build and distribute a (commercial or free) 3d or game engine upon Blitz3D, then you can also use BVM for that.
If you use BVM to allow the MOD community to modify your game to some extent, then you are not allowed to give a direct access to nearly each BlitzBasic command. The command set that you expose to the MOD community must be enough specific to your game, so that it can't be used as a replacement for buying a license for Blitz3D or BlitzPlus.

To sum up, don't forget that the primary use of Blitz is to write games with it. As such, you can of course write in Blitz anything that the best commercial games feature, including script systems. Knowing where to end in the access you give to the underlying engine (ie the Blitz rutime code) is just a matter a good sense. BVM is just one way to create such a script system (probably the best and easiest way so far), it does not add anything that you couldn't do by yourself (with a much higher amount of effort). Using BVM simply doesn't exempt you from ensuring that you don't do anything illegual in respect to BlitzResearch. Also you need a copy of Blitz3d or BlitzPlus to build such a host, so if anyone was badly disposed enough to want to do that, he could as well directly distribute his own copy of Blitz. In both cases he acts illegaly.

As a side note, it's also worth noting that writing ALL your game code in scripts is not the best you can do if you have a minimum of interest in the speed of your application. As stated earlier, BVM modules run slower than code compiled natively, and there is an ideal balance between the code that you put in scripts and the code that you let in your main application. This is why such an illegal host program wouldn't even be a good deal for the user to have.

All this is plain good sense, so hopefully you won't even have to think of it while using BVM.
------------




Koriolis(Posted 2003) [#10]
It is a blitz code.
No it isn't. Precisely, it doesn't contain your source code. Your exe only contains some symbols (function names, and so), and your compiled code (plus the common code, included in every blitz exe).
The exe is an already compiled game, that runs the commands in the bottom of itself.
Indeed, all the built'in commands are already compiled into the runtime.dll, and this one is included in your exe, and your own (compiled) code is added to that. But again, it is in its compiled form.

I suppose that virtual machine uses Blitz3D's compiler to compile it.
No. I made my own compiler which emits bytecode that my virtual machine executes. All packed in a single DLL.
Incase it doesn't, it's illegal.
I don't get it, it's illegal if I DON'T use the blitz compiler?!?


IPete2(Posted 2003) [#11]
I think if you have debug on when you make your executable, you can see more in the compiled code - but it is machine code in its .exe form.

IPete2.


podperson(Posted 2003) [#12]
I tried to replicate the results discussed here and can cheerfully report that the source code is NOT found in the exe -- whether or not debug is enabled.

There is a bunch of readable text there: the function stubs DO appear as _fCreateCube, and some stuff like the names of function parameters seems to be there.