Scripting

Blitz3D Forums/Blitz3D Programming/Scripting

Drey(Posted 2004) [#1]
Question:
What have u done for scripting or what have u seen?

Thoughts:

Alright, scripiting is something very important to me because i want my games to be cimematic.

Now i've been thinking about this, and for a while, i've been thinking of creating a interpurted language. Something that kinda works like Visual Basic. Just double click the Actor, Prop, or whatever and it breaks out a script editor. But the scripts will be broke down into Events that happen on the object itself.

Example:
Event Actor_(Name)_Move()
;Scripting
End Event

Event Actor_(Name)_Collision()
;scripting
End Event

So when an actor moves, it'll check to see if a script bank doesn't have a value of zero. If so, then it'll run the script stored in it.

Though i thought of many things for opitimizing the process, i'm sure it'll still, over all, add at least add a good amount of millsecs to the loop.

Now, i've been thinking, instead, just to load objects in the map editor. And they have Handles, as many as the editor wants to create. So u can have groups and such.

Object in group: "Second Wave", ID:2 ; "Primary Targent for Second Event", ID:0

Then, blitz3d itself, u make the "scripts" by creating custom functions for produce whatever checks and events u want. So example. Say u had an Object and Wave 1. U want want an Event to happen once all objects in Wave 1 have been destoryed. U'll have custom, per level, functions that check for these things. So u can make a quick loop to check for all the objects in Wave 1 and see if all their life values = 0. if so, then it'll start up the next event.

The problem with that is, once, u aren't coding in the editor so much. Problem two, i'll have to compile the whole project over and over again.

The Plus sides are the speed gain, direct access to the objects properties and easy creation of your own types u want for that particular level.

With the interpurted language, i can just have a quick "compiler" and just port it straight into the engine. No recompiles of .EXEs and such.

So i'm just tryin to figure out the best way to handle the job. Any ideas are welcome. Thank you for reading.


wizzlefish(Posted 2004) [#2]
What is scripting?


Drey(Posted 2004) [#3]
A way to make events happen. Like when u're walking, and then a wall busts open and tons of enemies come rushing in. After u killed all of them, the ground(will camera) starts to shake and some dude kicks down the door behind u. Some crazy Coppers come down, blows up the roof and starts firing at u too with guys jumping out of the drop ship.

Just a sequence of events that happen off triggers and such.
I can be a simple as a door opening or some cinematic scene.

It can also change the way your game acts too.


wizzlefish(Posted 2004) [#4]
OK...so it has to do with triggers and events, and stuff like that? OK - I've heard of it before.


Drey(Posted 2004) [#5]
Glad we're on the same page. So anyone have any input?

Sidenote: Half life 2 is the best game to come out in years. I just picked it up. I need a way to customize levels! Just playing Half Life 2 shows me the importance of scripted scenes.


Techlord(Posted 2004) [#6]
A simple implementation would use collision shapes that executes a function/script upon collision. There are many ways to create collidable objects. You can use Blitz Collision, Meshes with Alpha set to 0, or Math Collision.

;Math Box Collision Example
If EntityX(player%)>=box_pos_x# And EntityX(player%)<=box_scale_x#
	If EntityY(player%)>=box_pos_y# And EntityY(player%)<=box_scale_y#
		If EntityZ(player%)>=box_pos_z# And EntityZ(player%)<=box_scale_z#
			box_collision%=True
		EndIf
	EndIf
EndIf
You can either hardcode the action or use a scripting sytem like BlitzScript3D.


Drey(Posted 2004) [#7]
Yea, i understand that. I have a whole system figure out for that. I'm just wondering on some scripting ideas. i'll check out blitzscript3d. thanks.


Drey(Posted 2004) [#8]
Ok, i'm checking out the BlitzScript3d. Looks like it could be what i'm looking for. I'll look into this further.


JaviCervera(Posted 2004) [#9]
BlitzVirtualMachine is the answer.


Techlord(Posted 2004) [#10]
BlitzScript3D is work in progress. However, its developed with Blitz3D and FREE!


Koriolis(Posted 2004) [#11]
Drey, what you expose are precisely the reasons why I wrote BlitzVirtualMachine.
To evaluate it, follow the link in my sig.
It's not free, but VERY cheap, and with cool features you might like (like the simple fact that you'll write your scripts in plain BlitzBasic, or how easy it is to customize it to your very own needs).


Strider Centaur(Posted 2004) [#12]
Im glad there are so many tools for blitz, but has anyone been tracking the cost of all of this. Im over $300US with all these add on and what not. LOL

Anyway, Iv been saying for a while the solution is something a bit more capable like LUA as a scripting language, but the callback issue seems to be the road block on that. LUA is probably one of the best scripting languages in the world, especialy for working with games and other typicaly graphic orianted applications.

I see that BMX looks like it will be getting a LUA module soon, or at the very least access to the LUA dll, so I'll probably be upgrading to that as soon as PC version is released.

BVM looks sweet, but don't see paying money to code in Blitz( Im not saying BVM is not worth $15, or $50 to some, just not to me.). If I want to open up my game subsystems, a simple DLL interface and wrapper for a more powerfull scripting language should be all that is needed.

Again, I am not saying BVM is not good, or a valuable asset to the Blitz tool set, I am just saying I don't want to use Blitz in my projects as a scripting language when, IMHO, the goal of a scripting language should be to allow for more efficiant use of systems not accessable from within Blitz. I just don't see the benifit of locking people into the same limitations with the scripting language as with Blitz. Examples would be, being able to better access sound subsystems and devices, many of which you can not do very well in Blitz. Using a better language for scripting while requiring a little more work on the part of the developers( having to learn the scripting language too ) just opens so many more doors.

So, I am looking at creating a wrapper for a alternitive Scripting Language. I know LUA, PERL and PYTHON can all be compiled into .dll. However, LUA looks like it uses call backs, that I do not think can be done with Blitz's userlib interface, so Im probably going to try PYTHON. Really any Runtime Interpreter or byte code compiled langauge should be usable. Hmm, wonder if I could make a native interface from JAVA?


wizzlefish(Posted 2004) [#13]
For a door opening, and if the door was an MD2, couldn't you just do this?
If EntityDistance(player, door) < 10
    DoorOpen()
EndIf



wizzlefish(Posted 2004) [#14]
It's pretty good. (well, it LOOKS pretty good, anyway)


Koriolis(Posted 2004) [#15]
BVM looks sweet, but don't see paying money to code in Blitz
I don't think using a scripting system has much to do with the need in another language. So using the same language as people are accostumed to (and above all a simple to use language, which is perfect for scripting) is an advantage IMHO. It means an easier use, no extra learning needed, and an easier integration with the main application.
If I want to open up my game subsystems, a simple DLL interface and wrapper for a more powerfull scripting language should be all that is needed.
Well, it all depends on what you're expecting from a "more powerfull scripting language ". It seems you're simply looking for a more powerfull language, the "scripting" part doesn't have much to do with that.
Anyway, BVM is precisely going to be notably more powerfull with its upcoming language extensions.


BlackD(Posted 2004) [#16]
BVM is precisely going to be notably more powerfull with its upcoming language extensions.

1. Do you mean, commands than run certain functions to do a bunch of stuff, rather than straight command-to-command scripting? Ie, adding basic algorithims that should be in Blitz but aren't? :) eg. two-way IP conversion

2. Can you write your own command set in BVM which runs functions rather than using the Blitz commands?

3. I don't expect this, BUT.. can a BVM script run another DLL that wasn't compiled as part of the original program? For instance, say I want to add usage of FREEIMAGE.DLL on in an add-on script I'm writing, can I call that via the script and it'll run as normal? :) It's okay if you say no - I don't know any other scripting languages that can do that except Source. Even the DOOM3 engine can't. :)

+BlackD


Koriolis(Posted 2004) [#17]
1) No, but BVM is already entirely customizable, and you can make ANY function (including your very own functions) accessible to your scripts. So the set of commands you provide to the script is entirely open and up to you.

What I was really talking about are some extensions I'm making to the core BlitzBasic language to make it more powerfull. Like OOP (much like in BlitzMax), function pointers etc.

2) I guess point (1) answers that. Yes you can expose any function to your scripts, and actually you can as easily expose types and global variables

3) You mean use in a script a DLL that was not in advance linked to the main program?
Then the answer is yes and no. No, you cannot in this case call the DLL function directly, but you can still use CallDLL, provided you exposed CallDLL to your script in the first place (as well as PokeInt & co, which are needed to use CallDll). Note though that CallDLL works only with DLLs specifically written for Blitz using a special convention.

Now, if the DLL usage had been planned from the beginning then for sure it's even easier: just compile your main program in such a way that it can access a DLL (this simply means having the right ".decls" file), then list the DLL commands in the command set file (very much like in the .decls file) and voila.