View Single Post
Originally Posted by box View Post
Ah! Fair enough, I have a better understanding of what you're trying to do now.

If I'm correct, LuaSocket includes a core.dll file that you could potentially inject into toribash.exe. I have absolutely zero experience with that so I couldn't really help you there (and honestly I don't even know if it's technically allowed, but eh), but a little research on DLL injection may point you in the right direction.

Other than that, probably the way that I would do it is a direct socket connection to the game server via Python. As the client-to-server communication is entirely unencrypted, yes it is possible to send and receive data as if you were a Toribash client. You'd have to familiarize yourself with the protocol (it isn't too difficult, use Wireshark or something) but in theory I think it's possible. From what I know there isn't any complete documentation on the server protocol.

As a last resort, maybe you could try some clever workaround using text files (e.g. writing moves as they happen to a text file while running a Python script that reads the file every second or so, does what it needs to, and writes another file that the Lua script could read before executing a move). I realize that both of these options sound pretty tedious, but I don't have much knowledge on this general subject, as in the past most people have generally just worked with what they had.

Update below

I have thought of injecting DLLs into game, but I also wondered could this done by replacing Toribash's lua5.1.dll with my own binary. If only I could allow Toribash to look for .dlls while lua script "require"s something, that would be enough (hopefully). At the very least I seem to be able to include luasocket's core.dll functions in the Toribash by replacing the lua5.1.dll, but I do not know (yet) how to proceed from here. I figure this is what the lua_cFunction etc functions are for.

For networking sniffing: That's a good suggestion I did not think of. Sadly it seems the free-play option (against uke) does not seem to send anything outside (figures), so it can not be used there. Additionally feeding actions this way would be bit rougher (need to craft correct packages)

As for the "file communication": I started implementing this, but indeed it is rather cumbersome and feels wrong on many levels I decided to look back into luasocket ^^.

Thanks for the answers tho! If you (or other readers) know how to help me with the .dll stuff, I would appreciate any help. Otherwise I will start looking into the "file communication" again.

Edit/Update:
During pondering I thought to myself "Man it would be nice if I could replace that whole lua library Toribash uses...", only to realize LUA is open-source and everything.
A painstaking setup of compilation environment on Windows, a couple of dozen lua compilations and buuunch of random copy/pasting of files around I finally managed to arrive to my destination:

Image



I'll start finishing up the code right away, and hopefully have something more tidy to share soon enough (I figure I need to ask permissions from developers on if I can share this stuff ^^). Who knows, maybe this turns out to be something quite fancy!

Thank you for providing food for thought!


-----
Sorry for double post, but editing of my previous post just results to blank page.

To avoid looking like a total imbecelle, I realized that these limitations are implemented in startup.lua file, so no need for fancy deeper "hacking" ^^. Oh well, it was still a fun project!
Last edited by Miffylin; Mar 23, 2018 at 12:11 AM. Reason: <24 hour edit/bump