GameScript/Scripting

Blitz3D Forums/Blitz3D Programming/GameScript/Scripting

BLaBZ(Posted 2009) [#1]
How does GameScript or any scripting language interact with your main application?
What can I do with a scripting language?
Can I control variables, add functions etc?

Thanks!


Yasha(Posted 2009) [#2]
How elaborate do you want it to be? A scripting language is only different from any programming language in implementation, so what you can do with it is limited by what you design it to do. Generally controlling variables and adding your own functions are pretty core features.

By the way, there's a new Blitz3D scripting language in development right now.... features including custom types with methods, dynamically resizeable arrays and full access to Blitz3D functions and Types. Oh, and this time, it'll have integers, and won't be GPL. (Free, BSD-licence, any other feature requests?)


Ross C(Posted 2009) [#3]
From my knowledge of scripting, it is mainly used to change things when an application/game has been written. Adding the ability to use scripts, makes your finished game/application, far more flexible. In a way, it's like programming, and using your game/application as a complier.

Uses for this can be AI for instance. You create your game and have the ability to use scripts. Then when you want to add or change the way enemies behave, you simply change the script, without touching the code, or bothering about anything like that.


ZJP(Posted 2009) [#4]
Hi,
Try this ;) http://www.blitzbasic.com/Community/posts.php?topic=83975

JP


Gabriel(Posted 2009) [#5]
As Yasha says, it can do anything you let it do. Scripting languages (generally) don't just automatically decide what needs to be done, they let you decide what to bind and they bind it. If you wanted, you could bind every single Blit3D function and then write an entire Blitz3D program in Lua or Python. Or you could if Blitz3D had all the language features necessary. Without pointers, it can get a little bit tricky.


BLaBZ(Posted 2009) [#6]
So there's GameScript..

http://www.blitzbasic.com/Community/posts.php?topic=69531#964204

Would I be able to access every Blitz3D function with GameScript?
or Would I need to "bind" specific functions?


Gabriel(Posted 2009) [#7]
JohnJ says

The only way to interface the script to your code is through functions which you add to the scripting language through "GameScript Functions.bb"



Yasha(Posted 2009) [#8]
you could bind every single Blit3D function and then write an entire Blitz3D program in Lua or Python


Binding every Blitz3D function would raise a few eyebrows, of course. I believe GameScript's licence forbids using it in this way. It's something of a grey area; you should really only expose those functions it would be meaningful for a modder to change. You shouldn't really be handling (comparatively) low-level things like loading, mesh creation or rendering in the scripts.


BLaBZ(Posted 2009) [#9]
Agreed, I would like to use my own functions, but these functions include a lot of Blitz's functions


Gabriel(Posted 2009) [#10]
Well I'm sure it would raise more than a few eyebrows, sure , but I was illustrating the technical capabilities, not offering a treatise on the moral implications of interfacing with third party libraries :)


Mahan(Posted 2009) [#11]
I've bought BriskVM2 a couple of weeks ago. It was a little quirky to setup at first (mostly because of lacking or incorrect documentation), but when I got it running it was cool.

The syntax is "BlitzMax:ish" so you can do OOP and it has reflection. (and note that this means that you can actually write a program with OOP principles that works within a B3D runtime app). I've found a few "strange" things like that the language does not use boolean evaluation left-to-right as is standard is most languages today, but no real show-stoppers (so far). Also there are other additions in the language, compared to BMax, like real encapsulation (private, friend, public methods).

Under the hood you attach a VM (virtual machine) in a userlib-dll, and you can choose exactly which functions from the main language you want to make visible for the scripts (and vice versa).

Languages supported are Blitz+, Blitz3D, BlitzMax and a few more. (I have only tried it with Blitz3D though so far)

You can feed it with sourcecode from strings or files and as it (as most VMs) use a "byte compiled" format, you can also choose that the mainprogram only uses precompiled files.

The speed is quite good for being a script, compared with native b3d (in my basic tests with loops etc) it is ~3-10 times slower than the "native b3d". I haven't really tried the overhead when doing many calls into the native program though tbh.

The script editor is a bit bugged (beta quality). Never lost any code or anything drastic like that, but when editing, sometimes selecting text fails and when you use the code completion, the editor insist on "eating up" 1 char after the current position (so you always have to write a space or something and then "cursor back" 1 step, so the editor eats you space instead of the EOL :-)

But since it only costs $15USD (for the indie license) i bought it just to play around, and had a great time so far.

There is a demo-version also to try it a for free. Demo version is identical with licensed, but has a 10 min timelimit in the VM-dll.

(disclaimer: I'm in no way affiliated nor even had any contact with the author. This is just my personal review)


Mahan(Posted 2009) [#12]

Binding every Blitz3D function would raise a few eyebrows, of course. I believe GameScript's licence forbids using it in this way. It's something of a grey area;



Well, depends of what you do. If you would build "your own language" based on a script-language+B3D and provide all the goodies from Blitz3D and then release this product in public, thats clearly against the license of b3d (and also often the script language itself)

But suppose that you build a script-based program/game which has a internet update feature that makes it possible to update the program by only sending over small strong encrypted and checksummed class/bytecode files to make sure that only you can provide these patches/extensions, it should be ok, shouldn't it?


Agreed, I would like to use my own functions, but these functions include a lot of Blitz's functions



Sure, but all depends on the level of interface. If you for example would like to add scripting features to a game for your users and you provide a few functions like GetCurrentPlayer(), GetNearestPlayer(), AttackPlayer(), GetPlayerHP() etc, that would not "expose" enough of the base language for your users to write their own separate b3d-apps.


Rroff(Posted 2009) [#13]
And now we have fast pointers - you can do function call backs, etc. in the game script!


Mahan(Posted 2009) [#14]

And now we have fast pointers - you can do function call backs, etc. in the game script!



Could you elaborate a little, please?

How does this conceptually work?

Callbacks into the native b3d functions?


Rroff(Posted 2009) [#15]
Maybe call backs was a bit of a wrong way to put it...

but it would allow much more flexible functionality in the script in regards to functions.