New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Lua API. #5190
New Lua API. #5190
Conversation
That's a lot of code, i think you deserve a beer! |
You will need to change the package-all.sh, Makefile install section and the NSIS file for the Windows installer. |
🍻 |
@@ -74,6 +74,9 @@ | |||
<Package>mono.nat</Package> | |||
<HintPath>..\thirdparty\Mono.Nat.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Eluant"> | |||
<HintPath>..\Eluant.dll</HintPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "..\thirdparty\Eluant.dll"
Thanks for the detailed review @pavlos256! I'll start working through these over the next couple of days. |
} | ||
|
||
[Desc("Calls a function after a specified delay.")] | ||
public void RunAfterDelay(int delay, LuaFunction function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should move to Trigger.AfterDelay(int ticks, LuaFunction func)
.
Figured it was easier to get this out of the way now. Fixed nits, and sorted out the Eluant changes. See https://github.com/pchote/Eluant/ for the custom version included in this pr. |
@@ -240,5 +243,40 @@ public void Kill(Actor attacker) | |||
|
|||
health.Value.InflictDamage(this, attacker, health.Value.MaxHP, null, true); | |||
} | |||
|
|||
#region Scripting interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this and the other Lua-augmented classes partial
, with all the Lua-specific bits in their own file?
Updated with default parameter support, addressing @obrakmann's concern. |
|
||
namespace OpenRA | ||
{ | ||
/// <summary> | ||
/// 3d World vector for describing offsets and distances - 1024 units = 1 cell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the XmlDoc here? It integrates into IDE tooltips and is kinda helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency. They aren't used anywhere else in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we should document this somehow though #4372.
I think Eluant.dll should be added to the Makefile's COMMON_LIBS |
It already is? |
You're right, it's there. Sorry, I was probably looking at the wrong branch. |
Overall I'd recommend you break lines more often. |
Updated with the more fixes. |
# Copy files for OpenRA.Game.exe and OpenRA.Editor.exe as well as all dependencies. | ||
make install-all prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" | ||
|
||
# Native library dependencies | ||
cp "$DEPSDIR"/* "$PWD/packaging/linux/$ROOTDIR/usr/lib/openra/" || exit 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this here instead of in the Makefile will probably break all thirdparty package installation upon update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand they probably don't want our native binaries bundled so I guess it is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are OS-specific deps, so we don't want to do this in the (theoretically) platform-agnostic makefile.
In the best case, we would then need to go and delete these files again in the OSX packaging script, which is ugly.
This was difficult labour. Thanks. |
Pinging downstream maintainers @cerebrum, @ckorn and @hasufell as we made a tough decision to bundle native libraries, because of http://www.mono-project.com/Config_DllMap limitations and new versions not being available in LTS distributions. This will require some additional |
Also pinging @xaionaro as this might disrupt the Hetzner auto-update scripts as |
That does not look right. These kind of things should never happen. Instead, someone needs to make debian stop this crap. Otherwise it should be fixed on related consumer packages, not library level... but I don't know about openSUSE policies. Also mind that the pkgconfig files of lua are hacked as well. If there is something actually wrong, then it can be fixed upstream at lua. Instead debian uses wrong approaches to ship lua and ends up in their current mess. If we don't follow common interfaces and standards and add random hacks like debian does, then we encourage people to do the same and help spreading wrong usage of distro-specific pkgconfig files, uncommon library SONAMES and so on. This isn't the first time happening, there was way more serious breakage (like skype linking to non-existing SONAMES and modified libraries only present in debian). Make people aware that debian is bad for development and don't do as they do just because it's the easiest workaround. |
I agree and hate Debian/Ubuntu for it, but sadly they are the distribution the majority uses or bases their own ones upon. Also note how you just received a WONTFIX 1 year ago without further comment. This does not convince me that we can start to reason with them. In the end you are always fucked, because you get treated with "It works on Ubuntu, not on SUSE, you suck!" and everyone claims that Linux is not a sophisticated work platform because no one adheres to standards. I will probably experiment with http://software.opensuse.org/package/openra and invent a |
FWIW, the naming convention used by Debian's lua packages is in accordance with their policy manual. Good luck persuading them to change that. |
It wouldn't be so bad if they provide a proper abstraction layer that prevents people from using these library names directly. FYI... gentoo does a lot of very terrible hackery to make python, ruby etc work the way we want. But that is hidden from the developer/user. In contrast... changing names of pkgconfig files is so terrible, that I don't know what to say.
Can you not just fix that in the code, so that it tries to load different libs in that order: liblua.so.5.1, liblua.so.5, liblua.so, liblua5.1.so? Also mind that lua upstream doesn't even support shared libs in the first place (as in, no target in the Makefile). They were unable to get it working on all supported platforms without libtool (they didn't explain what's wrong with libtool). Not sure why that is any reason, but anyway. Just saying that the "5.1" etc are pretty much guesswork. That however isn't a problem as long as you use the pkg-config files which obviously isn't possible here. So technically... this is already an unsupported (but reasonable) hack, since static-only libs are a security problem. |
In IRC I was told that @xamarin uses |
Does current bleed servers work right? (on Hetzner) |
@xaionaro Yes, it does work. Looks like the dedicated servers don't require Lua at all. |
@Mailaender, ok. Anyway notify me when the release/playtest will be, please :) |
We are also trying to persuade @lua to properly support shared libraries. |
On an almost unrelated note: is it possible to use the static lib with C#? I don't know enough about that language and mono. |
You always use some kind of wrapper. See https://github.com/cdhowie/Eluant/blob/master/Eluant/LuaApi.cs on how the bindings interact with the Lua DLL. |
That doesn't tell me if you can achieve the same with a static lib. |
I think you would need to compile the static lib into mono, which is not desired. |
Ouch, yeah. |
I brought back the jets in https://github.com/Mailaender/OpenRA/compare/migs-lua-desert-shellmap but I am not sure if it is worth bringing them back as I don't really see them on my small laptop screen. |
This introduces a new scripting API built on Eluant and the native lua library. The main focus of this implementation was building a self-consistent and self-documenting API (generated using the
--lua-docs
utility command, and available on the wiki). Secondary benefits are that it is faster than Kopilua and doesn't leak memory everywhere.This is going to take a while to properly review, so i'm filing this now. There
are twois one main TODOs left to finish:Packaging changes: we can use the system lua for linux platforms, but will need to ship lua on Windows and OSX. We should also credit the new thirdparty bits in AUTHORS.Eluant.dll includes a bunch of now-redundant changes. I need to create a public fork, revert the changes we don't need, and file upstream prs for the ones that we do.This implements enough of the API for the shellmaps, but no more. A future PR will introduce a
ScriptPlayerProperties
implementation that exposes mission objectives and victory conditions.