Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Product Chat / [WIP] Lua for FPSC

Author
Message
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 27th Apr 2013 12:09 Edited at: 19th May 2013 05:49

LuaMod
Lua scripting for FPSC Classic

Current development version: v0.1.0 (pre-pre-pre-alpha!)
Current public release: Scripting prototype (not in engine)

LuaMod will be an absolute scripting overhaul for FPSC, it will completely remove FPI and replace it with the Lua scripting language.

You will have direct access to many DarkBASIC Professional commands, meaning you can do many more things than you normally could. This also means that you can make a mod for FPSC without actually modding its source code due to many parts of the engine being exported into Lua scripts.

I have been exploring many concepts on how I should make the final resulting mod execute scripts. My current idea is that in the editor, you assign a single script to an entity, and you will have two areas labeled "Appear" and "Main", in these sections you will write the name of the function to be executed for the respective mode. For example, in the editor I could have an entity's script section set up like this:

Script: "scriptbank/lua/default.lua"
Appear Function: "Appear1"
Main Function: "Main"


"Appear1" is going to be a global function to replace the "appear1.fpi" file, as you probably guessed, there'll be "Appear2", "AppearWithHeadshot" and all the others as well.

The default.lua file looks like this:



This is the current functions list:



There are also a few functions that are coded but not yet implemented (passed to Lua).

Credits:
Barnski - For his awesome Lua plugin
IanM - For his awesome Matrix1Utils plugin collection

-TZK

Attachments

Login to view attachments
s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 27th Apr 2013 13:38
I do love your out of the box thinking when it comes to mods with you.

The many mods you say you going to start and never complete due to the fact that you looking at stuff thats to hard for your skill set or just to hard without having to re-write a lot of the engine.

Most the stuff you thinking of adding has been thought of before but just don't work that well in the engine once added.

You have some great ideas but in practice just don't work very well.

Lua is a great way to speed up scripts in the engine but there is a few problems this may cause adding this feature and why its not been added before.

1: All the scripts in the engine needs to be changed to benefit from the speed or its pointless.

2: will people have the time to learn a whole new scripting language.

3: This again a pretty big project and is it worth ya time as all commands will need to be changed for the same reason it pointless if you don't.

I feel you need to start looking at more realistic goals instead of making thread after thread about the next big mod you working on and never complete.

It just make you look like someone who don't know what they talking about and not a good look.

Don't get me wrong you done some good work on the community mod but again you added stuff that don't work that well like bigger map size its pointless because the 2gb limit maxes out already on the map size it is now.

I can crash the mod very easy with a map that build ok in a normal map because of the extended map size.

Sorry for the rant and I may come across getting on ya case all the time but I do have great respect in what you do just feel you looking at goals you never achieve.

Do something smaller and show the forum when its done.

The way you going people will say another fakeware project by zombie killer.

As always I wish you all the best with your project and hope you prove me wrong.

Please prove me wrong and have a demo out very soon.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 27th Apr 2013 13:45 Edited at: 27th Apr 2013 13:47
@s4real
I agree with a lot of my projects failing, that's because I usually announce them before anything has been done. I've been working on this one for a while and I actually have it working quite well.

I should hopefully have a demo out soon.

Quote: "Sorry for the rant and I may come across getting on ya case all the time but I do have great respect in what you do just feel you looking at goals you never achieve."

Nah, it's fine. It's just constructive criticism, I'm completely fine with it and I understand.

-TZK

s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 27th Apr 2013 14:25
Quote: "Nah, it's fine. It's just constructive criticism, I'm completely fine with it and I understand."


I'm glad you look at it that way because thats all it is nothing personal at all and I look forward to a demo.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 29th Apr 2013 18:57
I had purchased the DBPro version of LUA and was going to incorporate it into my mod but then it seemed more than I wanted to do at the time. I actually wanted it mainly for conversations with the characters.

I wish you well with this project and am looking forward to the demo as well.


I'm addicted to programming and coffee!
Meows
12
Years of Service
User Offline
Joined: 12th Oct 2011
Location: Totally over the Rainbow
Posted: 29th Apr 2013 21:17
The Zombie Killer , I am excited about this one!
Please please let me know when a demo is out?
I have actually used LUA and it would be a wonderful tool that may actually implement many of the interesting effects and goodies I want to put in a game but can't as the scripting is bad and won't always do what I want it to do.

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 30th Apr 2013 09:49 Edited at: 30th Apr 2013 09:51
@Flatlander
I was considering using the Unity plugin, but that is Lua 5.0. The plugin I'm using is Lua 5.1, plus it's free. Feel free to implement this into RPG mod when it's released.

@Meows
I should have a demo out soon, probably in a few months, maybe a few weeks. It all depends on how well the development turns out.

PROGRESS UPDATES / DEV DIARY #1
I've changed the way some commands are used.
From now on, something like getting or setting a character's health is not a built-in command. You create it by using a new feature I've been working on:
GetElementInfoInt(Element, Property)
GetElementInfoFloat(Element, Property)
GetElementInfoDword(Element, Property)
GetElementInfoString(Element, Property)
SetElementInfo(Element, Property, Value)

So, to get an entity's health and set it to 5 if it is 2, then you would do this:



I've noticed that looping scripts appear to crash the engine since they are constantly looping which isn't allowing the actual engine code to execute. This means that Lua is only really useful for modding parts of the engine rather than scripting entities. I'll be fixing this as soon as possible.

-TZK

fallen one
17
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 30th Apr 2013 13:37 Edited at: 30th Apr 2013 13:45
I think it would be better to make a 'visual' scripting tool, that makes it easier to 'make' not 'write' scripts rather than add new languages.

FPSC main feature is ease of use, scripting is where the product is getting left behind. Unity already has a paint in segments feature, they also have visual scripting tools so users dont have to 'write' scripts, reloaded or not, fpsc is in danger of being beaten at its own game. While TGC are chasing the strengths of others, they are in danger of forgetting the reason people buy 'their' product while they try and keep up with another mans game, always mind your own business, dont follow anothers business or you will leave yours behind following someone elses lead.


The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 30th Apr 2013 13:51
@fallen one
This is more based around advanced scripting abilities rather than making it easier to script, but I might consider making a scripting tool similar to UDK's Kismet when this is released.

-TZK

fallen one
17
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 30th Apr 2013 14:06 Edited at: 30th Apr 2013 14:07
That would be awesome, I think scripting needs pushing in fpsc, even though its called first person shooter, I think it lends better to rpg type games and immersive gaming, with the vast amount of media users can create just about anywhere, this feature is better used if the user creates interactivity amongst the immersive possibilities the vast media library creates, rather than static linear styles shooting games in the Quake / Doom genre.


s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 3rd May 2013 17:16 Edited at: 3rd May 2013 17:29
Quote: "I've noticed that looping scripts appear to crash the engine since they are constantly looping"


Yeah you will need to make sure that these scripts don't loop all the time as this will use up memory and have bad memory leeks.

Looking at the way you adding this it could be good for some new features but I feel this may use more cpu then the scripting is at the moment just have to wait and see.

I'm looking forward to the demo for this and see how well it perform if you get it right this would be a good feature

keep up the good work

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 4th May 2013 07:19 Edited at: 4th May 2013 11:55
@s4real
Quote: "Yeah you will need to make sure that these scripts don't loop all the time as this will use up memory and have bad memory leeks."

Yeah, it's a problem that's proving to be a pain to fix.

It seems that the demo won't support lua for complete scripting, instead lua scripts will be activated via fpi like so:



@All
What parts of the engine would you like exported to lua? I've begun to export a bunch of the physics stuff, and I'd just like to know what else you'd like to be able to edit.

EDIT
I've been thinking of changing the way scripts work. Instead of having separate scripts for Appear, Main, Destroy and Shoot, one script will have it all:



(That's only an example script, most of the commands are actual functions coded in lua, not functions that are pre-compiled.)

So what do you guys think? Would you prefer this, or separate scripts?

-TZK

Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 7th May 2013 20:19 Edited at: 7th May 2013 20:20
I am a big fan of using Lua. And found it awesome to hear someone was actually implementing it in vanilla FPSC.

A tip would be to call as much core lua functions as possible, example for this:



...one could use the Math library (and make use of math.random()).

Also instead of calling individual properties you could pass over a whole struct of data to a Lua Table.

Quote: " I've begun to export a bunch of the physics stuff, and I'd just like to know what else you'd like to be able to edit."


I would only do this if you want to scrap the old Physics Engine and implement another one.

Quote: "Instead of having separate scripts for Appear, Main, Destroy and Shoot, one script will have it all:"


Yup I believe this is the way to go! I went for only an initialisation function and update function in LS.

Good work so far TZK!

Like = Follow!
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 9th May 2013 10:05
@Red Eye
Quote: "A tip would be to call as much core lua functions as possible"

I was going to do this, but I'm not sure if Barnski's Lua plugin includes these functions.

Quote: "Also instead of calling individual properties you could pass over a whole struct of data to a Lua Table"

I was going to do this too, but the way I was doing it didn't seem to work.

Quote: "I would only do this if you want to scrap the old Physics Engine and implement another one."

Well, I guess that's one of the reasons. It's also since I want the main feature of this to be modability, so the user can edit things like gravity etc.

Quote: "Yup I believe this is the way to go! I went for only an initialisation function and update function in LS."

Yeah, I might go for an init and update as well.

Quote: "Good work so far TZK!"

Thanks!

-TZK

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 14th May 2013 11:09 Edited at: 14th May 2013 13:04
PROGRESS UPDATE / DEV DIARY #2
So scripts look less cluttered, and so you don't have to define them all the time, functions are now defined in a file called "luaFunctions.lua", you can still define your own functions in your scripts though. The luaFunctions file shouldn't really be edited, it's mainly just for stock commands.

I've also changed the way the EntityElement reading system works.
Instead of a command, I changed it to something like this:



However, this didn't work the way I wanted it to (code-wise), so now it's like this:



Also, none of it remains up-to-date. The variables are only the values they were when the entity was spawned, there is a workaround however:



This would give you the current health value.

This works because the "setEntityElement" command will set all the entityelement values to the current values for the specified entity element. So if you set it to the current entity element, it will basically update the variables to the current values.

I've also copied some command names from LightStorm, mainly for compatibility reasons, so you can use your scripts in both engines, but also because I suck at coming up with command names :p

PROGRESS UPDATE 2 (EDIT)
Sounds are now much more flexible and it's easier to use them as well. Here's how you would load a sound, position it, and loop it:



Sound commands so far:


-TZK

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 15th May 2013 15:11 Edited at: 15th May 2013 15:14
Three posts in a row!

PROGRESS UPDATES, AND SMALL PERFORMANCE PROTOTYPE!
I've fixed the issue with looping scripts, it all works great now!
I've also changed the way scripts are executed.

I've attached a zip with three small lua files (luaFunctions.lua, luaVariables.lua and luaExample.lua), this is a small example that shows a few of the commands, and tests the performance.

Feel free to mess about with it.

Just as a note, I was going to make an actual release of the engine with lua built in, but I'm currently stripping out fpi and setting up the parts of the engine that'll need to be edited, so it's not really in a usable state right now.

Attached:
luaDemo.zip

Enjoy!

-TZK

Attachments

Login to view attachments
Corno_1
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 15th May 2013 15:25
Quote: "Three posts in a row!"

It is very simple! I can not write in lua. Sometimes I could write in java, but I didn´t do it since a year. So the most community members have already problems with the fpi language, so this mod is just for experienced members interesting.

You did a great job, but I do not think that this will be a success, even if you bring this project to an end(bug free). Hope the best for you and your mod

Corno_1


The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 15th May 2013 15:38
@Corno_1
Quote: "It is very simple! I can not write in lua. Sometimes I could write in java, but I didn´t do it since a year. So the most community members have already problems with the fpi language, so this mod is just for experienced members interesting.

You did a great job, but I do not think that this will be a success, even if you bring this project to an end(bug free)"

I guess it all depends on whether the community is willing to learn a new language, only time will tell. If you know DarkBASIC Pro or C, then Lua will be much easier to learn.

Quote: "Hope the best for you and your mod"

Cheers!

-TZK

s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 15th May 2013 16:05
Quote: "You did a great job, but I do not think that this will be a success, even if you bring this project to an end(bug free). Hope the best for you and your mod"


Lua has many benefits to the old system like speed and more complex coding can be done for better features.

The main issue is, is it too late with reloaded coming out later in the year with better methods and performance enhancements.

@The Zombie Killer :- Nice little demo but would be great to see a working fpsc build but I understand there must be a lot of bugs and problems you need to sort out.

I feel this would be for the more advanced user who wants to make more commercial based games and wants to keep to v1.

It has a lot of potential but this system will need a lot of work and if you happy to add it then go for it.

If you adding it for a pay mod then I feel you wasting your time as people will move on to reloaded.



best of luck s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
Meows
12
Years of Service
User Offline
Joined: 12th Oct 2011
Location: Totally over the Rainbow
Posted: 16th May 2013 00:51
just downloaded the demo. Looking forward to playing with it a bit..

Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 18th May 2013 12:15 Edited at: 18th May 2013 12:16
Quote: "out later in the year with better methods and performance enhancements."


Scripting wise I haven't heard anything from FPSCR end's (correct me if there is news on it) thus so far as I know TZK made fpi redundant with his integration of lua. But as he said, its up to the community if they are willing to take the next step.

A well designed scripting framework would allow so much more, making it equivalent if not better than FPSCR.

@TZK: Are you filling the entityelement table by hand assigning each element with a value returned by a function which does a dbcall? Or are you directly passing the whole structure into lua. Script looks good!

Like = Follow!
s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 18th May 2013 14:47
Quote: "Scripting wise I haven't heard anything from FPSCR end's "


Sorry can't say to much about whats going on under the hood with reloaded at the moment but it having a bigger re-write than it was at first.

Quote: "A well designed scripting framework would allow so much more, making it equivalent if not better than FPSCR."


100% agree but fpsc needs a big re-write for lua to work in my eyes.

TZK doing a great job and the scripts looks good but I'm not so sure we going to see a massive performance increase the way it looks how he adding it.

In my eyes you got to take the old system out and just have lua, one way you could do this is to have in the setup.ini or a mod.ini luascript=1 and the engine then uses just lua.

The if its set to 0 it uses the old system then people can have the option there no point mixing the two together because the old system uses too much all ready.

Just my point of view in it and wish him the best in it.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 18th May 2013 14:48 Edited at: 19th May 2013 04:33
@Red Eye
Quote: "@TZK: Are you filling the entityelement table by hand assigning each element with a value returned by a function which does a dbcall? Or are you directly passing the whole structure into lua. Script looks good!"

I'm filling it by hand, is there a way to do it without setting each element value by hand with a built-in function?

I'm currently doing it similar to this:

During initialization:


Setting a couple of values:


As you can see, the entityelement system is currently very incomplete. Which is why I'm using things like getEntityPosition and getEntityHealth to get many values.

@s4real
Just to clarify: I'm not mixing fpi and lua
I probably need to edit the OP. For testing, since I haven't completely removed fpi yet, I used an fpi command to execute a sample lua file.

I'm not really sure about performance yet either, then again, the project isn't in the optimization stages yet, it's moreso in the "just get it to work" stage.

Quote: "100% agree but fpsc needs a big re-write for lua to work in my eyes."

You'd be surprised how little the main source has had to be edited so far.

-TZK

s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 18th May 2013 17:39
Quote: "You'd be surprised how little the main source has had to be edited so far."


I didn't mean it like you can't get it to work with out a big re-write I meant you need a big re-write to benefit any speed increase.

But thinking about it you could add all the functions for lua in a new project and have a luascript=1 command like I said before.

This would infact be an easy way to add it.


I'm very interested in this a lot and hope you work it out, seems you doing some great leeway with this.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 19th May 2013 04:41
@s4real
Quote: "I didn't mean it like you can't get it to work with out a big re-write I meant you need a big re-write to benefit any speed increase."

Ah, okay, I just misunderstood you then. I guess when it gets to the optimization stages I'll probably have to rewrite a large amount of code.

-TZK

s4real
VIP Member
17
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 19th May 2013 05:05
@The Zombie Killer :- What ever method you use it still be a good improvement as lua is more flexable.

It would be nice to see some speed improvements with it due to scripts at the moment eat to much framerate.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 19th May 2013 05:46 Edited at: 19th May 2013 05:54
@s4real
Yeah, fpi needs a huge performance improvement.

PROGRESS UPDATE
I've discovered a way to define functions in DarkBASIC Pro code.
Normally, I'd have to do this in DBP:



And then this in lua:



But now I only have to do this in DBP:



The only downsides to this are that you can't customize the functions anymore, and if there is an issue, it would require a source edit to fix. Would you guys prefer the functions to be external or built in?

EDIT: Scratch that, if there was a bug with the command, it could still be fixed in the luaFunctions file. Since the functions in luaFunctions are defined after the built-in functions, if you had a function in luaFunctions with the same name as a built-in function, then the code in that function is what would be executed.

-TZK

Login to post a reply

Server time is: 2024-04-18 22:23:37
Your offset time is: 2024-04-18 22:23:37