Storing commands in a file

BlitzMax Forums/BlitzMax Beginners Area/Storing commands in a file

Mordax_Praetorian(Posted 2006) [#1]
As far as I know, when a compiled Blitz Executable is run, all of what used to be the code is loaded into memory

When every area of your game needs its own function to run it, this creates a rather big problem

What I'm wanting to do is to put a function in a file, and then load the function from there, and get rid of it when it is no longer needed, like C derevitives do with DLLs

Now, after searching the Blitz Wikki for both DLL and everything I could think Blitz might name such a system, getting 0 results, and reading the entire index of functions in the help file for something that looks right and once again being baffled by all of the things that arent explained in the slightest.
I conclude once again that the Blitz Max help file sucks and that you buys are my only hope.

Yes I know this is probably really basic, and simply a problem with naming things, but until one can search for concepts that arenbt possible to represent in simple language, this will have to do


Brendane(Posted 2006) [#2]
No, Blitzmax can't produce DLLs.

What do you mean when you say that every area of your game needs its own function to run it?


Mordax_Praetorian(Posted 2006) [#3]
Every part of the game world needs its own function to handle the procedings of events, placement of NPCs etc

I'm not wanting it to produce a DLL, I'm wanting it to load and unload DLLs containing Blitz Max functions, once I know how to do that, then I'll handle the creation of said DLLs

Or other files if DLLs arent apropriate

They dont even have to be full functions, I'd be perfectly happy if they were just compiled code, just as long as I dont have to have the code for every area in memory at once


Dreamora(Posted 2006) [#4]
There is no way for that unless you programm in a different language, create DLLs with exported functions and use that by calling it. (through api).

One thing you could do would be using LUA (or BPScript). But this wouldn't be BM nor would it be compiled. So one thing you might need to do is saving them to password encrypted zip for protection.


Brendane(Posted 2006) [#5]
It sounds like you might be thinking about your game in the wrong way. You should write your game engine such that it is data driven (that is, each level can be configured to drive the engine differently, ie, character placements, actions, events etc.).

This is how games are written - complex games will most likely use a script as Dreamora says to use as an input to drive the game for each level/section whatever. You can also just simply have level data files of your own creation - it doesn't need to be a script at all.


Mordax_Praetorian(Posted 2006) [#6]
So you're saying that I should have each area read in data for events etc from a file?

Ok, I see how that works

What about the password protected zips, how do I get Blitz to access those?


Brendane(Posted 2006) [#7]
Yes, exactly. You might have a data file for each level. For example : A shootem up game might have a level file to describe the things specific for each level, i.e. the background image, the music, the enemy positions any triggers, whether it is raining or not. Your game is the code which sets up each level depending on the data in the file.

There are a million ways to do this, it's all down to your imagination.

Blitz doesn't have support for password protected zips, but there might be a module out there which does (don't know off the top of my head).

For now I'd concentrate on actually having data to read from, then worry about protecting it if the need arose.


Mordax_Praetorian(Posted 2006) [#8]
Got it

Ty for the help


bradford6(Posted 2006) [#9]
this is what scripting is great for.

most games use a scripting engine such as Lua or Python which is an 'interpreted' language. this means that instead of compiling the source code into machine code, the interpreter runs each line in turn.

this makes for some interesting scenarios. for instance, you could have a section of code that actually creates a script to be run at a later time.

there is a LUA module for blitzmax. there is lots of info on lua for game scripting. try it out


Mordax_Praetorian(Posted 2006) [#10]
I would be happier making my own script - that way it can be designed specificly for working with the engine, I've some nifty ideas for this already


Dreamora(Posted 2006) [#11]
Even if you use them, you make your own scripts, as you must write functions in BM you expose to LUA or BPScript so the script can interact with your app at all :-)

The scripting language modules only give you a working interpreter and machine to run your scripts, as well as some basic functionality (which might be very important, like string manipulation etc in LUA. wouldn't know how to do usefull addons for WoW without them ;-) )