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:
-- get player distance from entity (helper function)
function fpi_plrdist(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
return math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
end
-- mimic FPI plrdistwithin (FPI condition)
function fpi_plrdistwithin(e, howmuch)
return (fpi_plrdist(e) <= howmuch);
end
-- mimic FPI plrdistfurther (FPI condition)
function fpi_plrdistfurther(e, howmuch)
return (fpi_plrdist(e) > howmuch);
end
-- check state (FPI condition)
function fpi_state(e, state)
return (e.state == state);
end
-- set state (FPI action)
function fpi_set_state(e, state)
e.state = state;
end
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