Scripts / Any chance of a fpi to lua converter?

Author
Message
MK83
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 2nd Feb 2014 05:42
Would this be possible? and before anyone

else says it, I'm lazy. lol

mk83 Productions



PM
MK83
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 7th Feb 2014 03:33
guess not.

mk83 Productions



PM
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 7th Feb 2014 08:07 Edited at: 17th Feb 2014 21:59
There were a few members that said they would gladly take this challenge on. But I don't see it happening too soon.

MK83
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 11th Feb 2014 02:30
What say you, Lee?

mk83 Productions



PM
BlackFox
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 11th Feb 2014 22:43
Quote: "Would this be possible?"




It is possible. Matter of fact, we have one ourselves since we run both FPI and LUA in our classic. It is not hard to do, since we work in a large variety of engines and script languages.



Quote: "Not for a long while.



But there were a few members that said they would gladly take this challenge on. But I don't see it happening too soon."




Unfortunately, it would be premature for such a converter to be released until TGC can verify their LUA module is in fact 100%, along with other issues. It would not do the programming individuals that make such an app justice if they made a converter only to have to change it to accommodate an issue and fix in FPSC-R. Unless they don't mind making change after change while BETA's are still rolling...



I'm certain once FPSC-R is more stable and the LUA scripting is solid, one such app will be presented.



There's no problem that can't be solved without applying a little scripting.
MK83
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 12th Feb 2014 05:49 Edited at: 12th Feb 2014 05:50
@BlackFox,Teabone, thanks

mk83 Productions



PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Feb 2014 01:48
I guess it will not be so hard to make, all we need to do is split each row in FPI by ":" and make "state" variable (default=0), set of "if" statements from the left side of : that will, if true, run set of functions from right side of :



Sounds easy but I doubt it'll be that easy



Also, we need is list of FPI equivalent functions, so that's why we have to wait until LUA becomes more stable in FPSC:R

no signature
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 14th Feb 2014 04:29
I'd assume the Dark AI commands would be a bit more challenging to work over to LUA.

kehagiat
11
Years of Service
User Offline
Joined: 16th Jul 2013
Location:
Posted: 14th Feb 2014 15:15
>I guess it will not be so hard to make,

>all we need to do is split each row in FPI

>by ":" and make "state" variable (default=0),

>set of "if" statements from the left side of :

>that will, if true, run set of functions

>from right side of :

Yes but what is the "state" variable in the LUA implementation? Is there one? And how does one access it?



Same question for all other variables that are accessible in FPI (e.g., entity's coordinates, orientation etc.). How does one access them in LUA? (That's what I was getting at in a previous post of mine).



>Also, we need is list of FPI equivalent functions,

Very true!



>so that's why we have to wait until LUA becomes more stable in FPSC:R

Also very true but also very trying for the impatient among us .



>Sounds easy but I doubt it'll be that easy

I think if one had all the info mentioned above it would not be so hard. Depends on the language one would use, too. Personally I would do it with Perl. I think with regular expressions it would not be too hard.



Thanasis

Whereof one cannot speak thereof one must be silent
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Feb 2014 16:31 Edited at: 14th Feb 2014 17:03
We'll make a state variable! LUA scripts run in game loop too, if I am correct, right?



A common FPI script looks like this:







I guess LUA script would look something like this. I'm not familiar with LUA (yet) so this is c-like-pseudo-language:







Now each IF block represents a line of FPI script and it wouldn't be so hard to automatically generate this code from FPI file. All we need is to create set of fpi_* functions in LUA that will do the work original FPI functions did. If that is not possible, then I'm failing hard before even started

no signature
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 15th Feb 2014 17:15 Edited at: 16th Feb 2014 21:42
Sorry for double posting, but I felt this is worth another post. I've looked a bit at FPSC:R LUA scripts and made a simple online fpi2lua converter:



http://www.avramovic.info/razno/fpi2lua/



Just paste your FPI script and press Convert! All FPI conditions are converted to LUA IF conditions with an "and" between them, while all FPI actions are converted to LUA function calls that are yet to be defined. All functions are prefixed with "fpi_". Comments are converted from FPI ;comments to LUA --comments, as well as description ("desc = ") which is converted to ordinary LUA --comment.



Please note: This tool is not usable at all at the moment as we are missing all the fpi_* functions, but here's how couple of them could look like:









Few additional notes:



a) All fpi_* condition and action functions accept exactly two arguments (even if they don't need them):

1) e - Entity that the script is assigned to

2) value - Value to check for fpi_* condition functions or value to set for fpi_* action functions. The value is everything right from "=" sign in FPI statement. If there is no "=" sign or anything after it, boolean false will be used



b) fpi_plrdist() function accepts only e (entity) argument, but it is a helper function, not fpi_* condition or action



c) All fpi_* condition functions must return boolean (true or false) based on the argument(s) they accept



d) All fpi_* action functions shouldn't return anything but do the job they are designed to do



e) FPI "state" action is using fpi_set_state() instead of fpi_state() which is used to check if state equals a number. This is done to distinguish checking state from setting state functions. If there are more FPI conditions and actions with same name, please let me know



f) I'm assuming here that the entity "e" object has property "state", but if that is not true and we can not define something like that, we will have to store global array of states (for each entity) or figure out another way to save the state of an entity



g) It would be great if we had something like PHP's "include" function, so we could store all fpi_* functions into, say, fpi2lua.lua and include it in global.lua file



h) I haven't tested generated scripts at all. They may even have syntax errors, but we'll work on them

no signature
kehagiat
11
Years of Service
User Offline
Joined: 16th Jul 2013
Location:
Posted: 16th Feb 2014 15:50
@avram : Great job man. What we now need (Lee?!) is a list of the FPSC-R / LUA internal variables. Then we can define all functions / conditions / actions which appear in FPI.



The "state" variable is a good example. I got your point that we can defin
J0linar
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 3rd Feb 2010
Location: Vienna, AT
Posted: 17th Feb 2014 01:27
Well done Avram,

there are plenty of old fpi scripts that could get ported with this (once we receive full access in fpscr:lua)



+1

http://j0linar.blogspot.co.at/
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 17th Feb 2014 11:56
Thanks people!



Regarding state variable, I wouldn't mess with existing state variable (if any) as our scripts may change it and it may affect other aspects of the game, UNLESS it's specifically designed to be used only by LUA scripts. If not, I haven't tested, but hope that we could use existing g_Entity array to store state of an entity, something like:







Or if g_Entity is not and will not be writable (though I doubt that), we can always define our own global array and store states in g_fpiStates[e]['state'] or something like that.



But all we can do now is wait until new beta is released to see what new LUA functions/variables will be available. After that, we should start defining some fpi_* functions

no signature
kehagiat
11
Years of Service
User Offline
Joined: 16th Jul 2013
Location:
Posted: 17th Feb 2014 15:20
@avram: Concur

Whereof one cannot speak thereof one must be silent
MK83
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 18th Feb 2014 03:32
@Avram,

mk83 Productions



PM

Login to post a reply

Server time is: 2024-12-22 01:36:16
Your offset time is: 2024-12-22 01:36:16