Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Whispers

Pages: 1 2 [3]
31
OXCE Builds & Ports / Re: [OXCE+] Lua Integration
« on: September 15, 2018, 08:53:33 pm »
Oh, and the only dependency is Lua5.1. It consists of a handful of source files and can be retrieved and compiled on any platforms with one bash call. You're using Boost in OXCE and OXCE+, so I hardly think the 1-2k size would make a difference.

32
OXCE Builds & Ports / Re: [OXCE+] Lua Integration
« on: September 15, 2018, 08:50:16 pm »
Hi Yankes!

Yes, I heard all about the yankesScript and I've briefly browsed through what you have there. Yes, you've done a really great job at making a logic graph, and I'm not trying to replace yours for the thousands of scripts that already exist. However, I do think there is a need for something more accessible to the modding community, and Lua fits that description. Instead of having to learn about the quirks of one language in order to make something unique, you can learn a language used by thousands of other games(or re-use your existing knowledge of Lua, if you are already familiar with it).

I can see that you are very much someone who cares about performance. I used to be that way also. LuaJit exists to fill that gap by precompiling the Lua on the target platform, if performance ever becomes an issue, which I doubt it ever will be. For now, I don't think it will be an issue. Back in 2006, I used Lua on Supreme Commander, and we had thousands of units running multiple scripts every frame, and that was 10 years ago.

Const correctness is an interesting topic, and one that even C++ developers often get wrong. Did you know that the C/C++ compilers(GCC, Clang, and MSVC) completely ignore const when it comes to optimisations(use preprocessor definitions if you want a true const)? Reason why is that you can easily un-const something without the compiler ever knowing. All it is is simply a hint to the programmer that they shouldn't modify the value. Anyway, I digress. I don't want to start a C/C++ standard discussion because those could go on for days. I do, however, want to discuss Lua :D

33
OXCE Builds & Ports / Re: [OXCE+] Lua Integration
« on: September 15, 2018, 08:04:23 pm »
Updated the OP... more updates to come

34
OXCE Builds & Ports / [OXCE+] Lua Integration
« on: September 15, 2018, 04:55:31 pm »
I started work on extending OXCE+ to include LUA hooks and so far the results are promising.

I wanted to start this thread to discuss the progress and also address any design considerations with how the OXCE+ LUA API is constructed.

First up, the progress.

I've set up a new rule which allows you to specify a script to load. The rule syntax is fairly straightforward.

Code: [Select]
game:
  script: scripts/game.lua

This will simply tell the engine that you have a script in <mod root>/scripts/game.lua. When a game is loaded or a new game is started, it then executes the script for the first time. When the script is executed, it is responsible for registering the hooks that it requires in the engine. Currently, it's implemented in such a way that you can only have one hook per script per callback, so you can call xcom.geoscape.register1HourCallback(function) multiple times, but it will only execute the last function you pass to it on every hour.

In the current version on github, there is one callback at the moment. I'll be refactoring the code a bit to make it more generic so other callbacks will be quicker to implement, however, start small and work your way up :D

With that working, the next steps are to add in a ton of global callbacks and hooks.

I set up the github repo. The repo with the Lua additions is here:

https://github.com/xxWhispers/OpenXcom

Why Lua? Well, to be honest, it's a widely known language that I have familiarity with implementing and developing with. That's literally the only reason why. Oh, and functions are data, which allows you to overwrite other functions to extend functionality in ways that are limited only to your imagination(and coding skills).

From a design perspective, I want to be clear that the idea is not to replace or port any of the existing code over to Lua. I don't want to port OXCE+ over to Lua. Instead, the goal is merely to provide the ability to get/set data internally without having to modify the engine code for new features.

With that said, there are things I do have in mind to allow you to extend certain features already built into the engine. For instance, one of my goals is to allow you to write your own terrain generation algorithms and hook into the existing terrain generation to allow you to overwrite or skip certain terrain passes. Another thing I want to allow you to do is customise almost every screen in the game by exposing the active UI elements and allow you to move/add/remove all UI bits around as you see fit. Then there's the obvious stuff, like being able to change soldier stats, add new fields, and completely new game mechanics(soldier mana stat anyone?)

Future plans:

* Have the ability to set/get existing base information such as stores, tiles, crafts, soldiers, etc.
* Add more triggers like onEnemyCraftDetected, onEnemyLanded, onEnemyBaseDiscovered, etc
* Have custom terrain generation scripts
* Have battlescape scripted events
* Hook into save/load game to allow mods to save their stuff.

Questions for modders:

* Should there be scoped/privileged Lua calls that are only accessible to certain mods?
* Any special requests for features? ( I have a feeling I may regret asking this :P )

So I'd really like to get your thoughts on this. Any questions, please feel free to give me a shout! I will be back here to post new updates as they come, so stay tuned!

Pages: 1 2 [3]