Forged Alliance Forever Forged Alliance Forever Forums 2016-12-13T00:01:21+02:00 /feed.php?f=45&t=13649 2016-12-13T00:01:21+02:00 2016-12-13T00:01:21+02:00 /viewtopic.php?t=13649&p=140440#p140440 <![CDATA[Re: Adding new built-in functions to Lua]]>
PattogoTehen wrote:
http://forums.faforever.com/viewtopic.php?f=45&t=5757

https://github.com/FAForever/supcom-se/ ... /scse/scse


Oha .. I guess at some point I would have arrived at something that looked like this. Why is this not being used actually, or is it?

And how did they get all those addresses? XD https://github.com/FAForever/supcom-se/ ... Linker.cpp

Statistics: Posted by snooc — 13 Dec 2016, 00:01


]]>
2016-12-12T23:50:06+02:00 2016-12-12T23:50:06+02:00 /viewtopic.php?t=13649&p=140439#p140439 <![CDATA[Re: Adding new built-in functions to Lua]]> viewtopic.php?f=45&t=5757

https://github.com/FAForever/supcom-se/ ... /scse/scse

Statistics: Posted by PattogoTehen — 12 Dec 2016, 23:50


]]>
2016-12-12T20:25:07+02:00 2016-12-12T20:25:07+02:00 /viewtopic.php?t=13649&p=140431#p140431 <![CDATA[Re: Adding new built-in functions to Lua]]>

Glad to hear that this might actually be useful :D

I just like to stress that all I just did was a quite simply proof of concept. There are several things that might go wrong here. One of the things that appear to have changed in SCL (Supreme Commander Lua) is the way garbage is collected. I tried to include a compiled version of Lua 5.0.1 (which appears to be the version being used by SC) but as I tried to run the code on stolen structs I was faced with the problem that the original implementations for registering functions did crash the game. One would have to look into that and sort out what we can actually do and what not.

I was thinking about laying a foundation for others to implement their own Lua libraries. My helloworld() can actually be called with

Code:
ext.helloworld()


inside Lua for example.

One thing that has to be mentioned is that for this hack I had to modify the executable. I know that this is not something one wants to do but it was necessary. There might be a way to not have to modify the executable by using e.g. WriteProcessMemory though.

I agree with you that indeed a few things could be done with this - we'd have to further investigate what's possible with that and what's not of course :)

Statistics: Posted by snooc — 12 Dec 2016, 20:25


]]>
2016-12-12T19:44:12+02:00 2016-12-12T19:44:12+02:00 /viewtopic.php?t=13649&p=140426#p140426 <![CDATA[Re: Adding new built-in functions to Lua]]>
Second and related thing is, that we can't open sockets from within LUA, for whatever reason that would be required.

Thirdly, we can't mount (or reload already mounted) directories which currently makes it impossible to automatically download and add missing maps without restarting the game.

Another thing is the ICE-adapter we're currently implementing; it's currently a standalone binary that wraps the GPGNet protocol. In theory, we could build the ICE support straight into SupComFA. I that would give us any benefit, idk.

I'm sure there are plenty more and crazy things we could do, those are just the ones that came into my mind :-)
If you want to be hardcore, you could substitute the pathfinding algorithm ;-)

Either way, we're always looking for talented developers, another C/C++ developer is something that would be helpful, too!

Statistics: Posted by Downlord — 12 Dec 2016, 19:44


]]>
2016-12-12T18:32:37+02:00 2016-12-12T18:32:37+02:00 /viewtopic.php?t=13649&p=140420#p140420 <![CDATA[Adding new built-in functions to Lua]]>
I've been working on a thing the last few days and today I got the first important thing working. In a few words: I hooked up a DLL in order to register new functions / libraries to Lua. Today I was able to do it the first time and run my helloworld() function while Supreme Commander was running.

It wasn't so easy because it seems those "slight changes" which are mentioned in the Supreme Commander Lua documentation are not so "slightly" after all - at least so far as I can tell.

However, the question I'd like to ask here is if this can actually be useful for you guys. Maybe I am not the first one who did it and the community decided against it already but I'd like to ask if this could be something of interest to us.

Some of you might have seen me asking in the FAF Chat a few things about programming an AI which can be controlled remotely. I am not sure yet if even though my hack works whether this is something doable but well - I can write arbitrary C functions, compile it into a DLL and run the code by calling it from Lua.

But maybe there are other things we're missing out in SupCom's implementation of Lua and maybe there's a way to do a few things about some restriction we're facing.

I already said too much. Please just let me know what you think about this. If the response is positive I'm willing to continue to work on it and of course share it with you guys. There's of course a lot more to say about this but first I need to know what you guys think.

BR; Stefan

Statistics: Posted by snooc — 12 Dec 2016, 18:32


]]>