My Idea For Scripting

My Idea For Scripting

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

My Idea For Scripting

Post by SinbadEV »

I think the best way to handle "scripting" is a perverted C++ based OOP

Inheritance, Units Are "Objects" they can have virtual "sub-objects" but this is not a neccessary feature... basically the engine is another "object" that calls methods on the unit objects. Class definition replaces both Weapons, TDF, and all the other random files we have, and so a peewee would be built to inherit the "generic kbot" object, and add include a "peeshooter" weapon that could also be used by, let's say, a jeffy.

There would be 4 types of variable...
- Internal variables, variables that the engine object doesn't care about (indexes for loops, heat and ammo... things that affect the script of the object but not the game), these would only be private and could only be accessed by public methods on the unit-object
- Solid Values, unchangeable properties things like max health and energy use, metal-make... maybe even system toggles like hover,canfly,leaves tracks.... that would define how the engine object interacts with them in standard methods.
- Open Values, same as Solid Values but allowed to change... this way if you need to make a unit that can change from a plane to a kbot you can... but it doesn't add any overhead to units that don't need the control... this could also be used to override the build in eXperience system... which would otherwise be inheritted from the parent "generic unit" class...
- Active Values, current health, experience, weather the unit is flying or not... some active values would fall under the "states" category, if for example you set a flying unit to a not flying unit, it would basically "land"... these would also include direct control over the objects in the s3o/model... one cool thing about this kind of control would be that you could basically have an attack that "tears a unit appart" and then the attacker would overide the target's built in death animation script...


basically you would impliment (or inherit and then optionally overload) a standard set of methods... basically things like "aimWeapon1" and "Activate" "Deactivate"... so essentially it would look almost identical to the current scripting language to a certain extent.

in order to stop some of the spegetti and possible conflicts, it would be possible to deactivate cetain methods at execution of certain methods, as well as allowing "kill" signals to be sent to a given method (with an optional "clean-up" method be called in a case like this.

I'm pretty sure I've made no sense here, but then I've never invented a scripting language before... I don't like the idea of using LUA because I think it would be a lot easier to just make our own "virtual machine" or whatever. Obviousely I'm not a programmer otherwise this would have made a lot more sense... Maybe someone who has figured out what I'm talking aboout could make example code for what I'm talking about.


C++ isn't acctually hard, it's just the pointer/libraries/headers/includes/variable control stuff that makes it any harder then JAVA... or Visual Basic for that matter... and that stuff isn't neccessary for a static implimentation like this...
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

Woohooo! Rehash of my old idea from a few months ago! Except my idea was far more flexible, and only slightly more demented and probably even easier to code :P :D
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

Link?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

why? Use Lua

I think that currently we're best looking at how other games used lua to script things, more specifically how will supreme commander do it?
Post Reply

Return to “Engine”