Page 1 of 1

Is there a way?

PostPosted: Fri Jul 18, 2014 22:09
by Tedypig
Is there a way to catch in-game chat and send it to external program? I'm making a program like Mclawl (for Minecraft Classic). I have a lot done, such as the settings input and writing to minetest.conf, I have a partial GUI made, but I wanted an in-game to/from console chat. The program would display in-game chat and the server owner can send messages back to the game chat. That way server owners can chitchat with players and send commands and such without having to login. (Yes, I know about the IRC mod, but this does that and more) I have tried to make a Minetest chat log and read from there, which works IF it closes and re-opens every second (a LOT of lag) and the same for sending messages, it must open/close every second.

This little project is fun and is helping me learn both Lua and Python. I hope someone out there can help me. Any help is appreciated. Thanks in advance! :)

--Tedypig

Re: Is there a way?

PostPosted: Fri Jul 18, 2014 23:03
by prestidigitator
I can think of a few possibilities:
  • Use the filesystem and carefully think about your directory structure, strategy for reading and writing files, etc. Remember that Lua cannot list directory contents on its own. You might need to either use single long files or a name scheme that allows you to detect new messages by trying to open specific file names. It sounds like you might already be doing SOMETHING along these lines, and it may be difficult to get it to perform adequately.
  • Create a modified client or server that'll act as a relay, by directly adding to the C++ code. This could get complicated, and probably isn't why you are asking here.
  • Finally, you can find or create a C library to extend Lua's functionality, and try loading it from a mod using package.loadlib. I haven't tried this myself, but I suspect it will work because I haven't seen any OTHER places where they have tried to sandbox mod code (e.g. I don't think there's anything preventing a mod from trying to open an /etc/passwd file or something). Just keep in mind that this is likely to be very platform-dependent, and could be a serious security concern if you distributed it publicly for use in servers. It could also easily create security issues for your own servers, so be very, very careful what you do with user input and stuff like that.

Re: Is there a way?

PostPosted: Sat Jul 19, 2014 01:24
by Zeno
prestidigitator wrote:Finally, you can find or create a C library to extend Lua's functionality, and try loading it from a mod using package.loadlib. I haven't tried this myself, but I suspect it will work because I haven't seen any OTHER places where they have tried to sandbox mod code (e.g. I don't think there's anything preventing a mod from trying to open an /etc/passwd file or something). Just keep in mind that this is likely to be very platform-dependent, and could be a serious security concern if you distributed it publicly for use in servers. It could also easily create security issues for your own servers, so be very, very careful what you do with user input and stuff like that.[/list]


I don't think it causes any more of a security issue than (non-sandboxed) Lua already creates, so I wouldn't be particulary concerned about that.

This might be the best option actually. If it were me I'd start with kaeza's IRC mod, strip out everything IRC related and start from there.

Re: Is there a way?

PostPosted: Sat Jul 19, 2014 07:21
by Calinou
Chat plus logs chat to file in the world directory.