Aside from the mod i've written (http://steamcommunity.com/sharedfiles/filedetails/?id=342911879) I have zero experience with LUA. However i'm not new to programming and find it hard to program in procedural fashion.
I've been trying to come up with a way to get object oriented programming with the current implementation of CivBEs lua. It seems some items have been left out most likely for security reasons and what not.
It seems that the class declaration is something that wasn't included. Not entirely sure why that is. I can't include the class file since the include method has been rewritten to only include items in the VFS and not include the actual LUA files. I'm not stuck on using that particular file. But has anybody been able to come up with a working object oriented approach to the lua with the game?
Now i know i can declare functions inside functions to get something like parent.child() but that isn't the same as many of the characteristics are different. For example i have CRUD (create, read, update, delete) actions that i use to interact with the database that can be called in any number of functions. I'd like to create an object for them and then extend that object with my table classes. Creating a makeshift orm if you will. Using the PRAGMA table_info(table_name) i can even get the table schema to initialize empty table objects for use on inserts and what not. Doing these sort of things with a function inside of a function just isn't practical and i might as well just leave it as is, a collection of one off functions invoked independently.
Does anybody have any examples of something remotely close to OOP? i know LUA can achieve oop but it seems like every attempt to do this in game literally crashes civ and i have to ctr+alt+del the game.
I've been trying to come up with a way to get object oriented programming with the current implementation of CivBEs lua. It seems some items have been left out most likely for security reasons and what not.
It seems that the class declaration is something that wasn't included. Not entirely sure why that is. I can't include the class file since the include method has been rewritten to only include items in the VFS and not include the actual LUA files. I'm not stuck on using that particular file. But has anybody been able to come up with a working object oriented approach to the lua with the game?
Now i know i can declare functions inside functions to get something like parent.child() but that isn't the same as many of the characteristics are different. For example i have CRUD (create, read, update, delete) actions that i use to interact with the database that can be called in any number of functions. I'd like to create an object for them and then extend that object with my table classes. Creating a makeshift orm if you will. Using the PRAGMA table_info(table_name) i can even get the table schema to initialize empty table objects for use on inserts and what not. Doing these sort of things with a function inside of a function just isn't practical and i might as well just leave it as is, a collection of one off functions invoked independently.
Does anybody have any examples of something remotely close to OOP? i know LUA can achieve oop but it seems like every attempt to do this in game literally crashes civ and i have to ctr+alt+del the game.