Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: The E on May 01, 2010, 07:43:52 am

Title: Feature idea: "Embedded" scripting
Post by: The E on May 01, 2010, 07:43:52 am
Note: this is not a feature request by any means. This is just something I think could be cool.

So, basically, why does scripting have to be confined to scripting.tbl? I think if it was possible to define scripts in ships.tbl or weapons.tbl, it would open up a lot of awesome possibilities.

For ships.tbl, defining scripts for stuff like "when ship turns in direction", "alters thrust", "fires weapon", etc could be the start of a comprehensive replacement for the animation code that is in the engine right now.

For weapons.tbl, being able to define script snippets that are run when a weapon is fired or impacts on a target could be a gateway to more awesome effects, not to mention more varied hit effects than just "target takes damage and gets whacked around a bit".
Title: Re: Feature idea: "Embedded" scripting
Post by: Nuke on May 01, 2010, 07:46:49 am
i should note that this _has_ been done with the engine to some degree at some point, but the idea was kinda rolled back because it was thought that a centralized scripting system would be better. i kinda thought it was a pretty cool idea at the time.
Title: Re: Feature idea: "Embedded" scripting
Post by: The E on May 01, 2010, 07:49:19 am
There is a place for centralized scripting, of course. But I can't see a reason why we can't have both, really.
Title: Re: Feature idea: "Embedded" scripting
Post by: Nuke on May 01, 2010, 07:57:13 am
you would need both. you need a global place to run generic stuff, stuff like gui code and parsers and whatnot. where scripting really lacks is with specific stuff. take laser guided missiles for example. for it to work with a centralized system (which i have done mind you, and which you will get as soon as i get my svn repo in order), you need to run loops to find and operate the weapons, run a meta system so you can keep track of what that weapon is doing while it exists, you have to do a lot of stuff that the engine already does (so your doing it twice). if its embedded in such a way that every weapon has its own little scripting namespace where you can keep variables and run code for that weapon only, it would GREATLY reduce scripting overhead and would generally make for a smoother integration with the engine..

this would also solve another major problem with scripting, code organization. i keep a folder in my fsroot where i keep a central copy of any commonly used script (parser, ect) and use lua facilities to run the file from any mod dir that requires it. this conflicts with he direction the engine is going (making proper use of user folders). if i could use more decentralized code, then i can say byebye to huge script files.

found a modular table that had used an embedded script
http://pastebin.com/pLZfJh6y