people playing: 92, servers online: 24, games played: 139,314,420 Top Player: Joel

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Jul 19, 2016   #691
Ylaric
Junior Member
 
Brown Belt
Join Date: Jun 2014
Posts: 12



Hi
Is there a function to determine which joint is currently under my mouse? I've done a bit of searching and found the "joint_select" hook. It works in singleplayer where you can select and edit both players' joints, but sadly it doesn't work in multiplayer (when you are a spectator)

As a workaround I used rough calculation using radius and joint screen pos, but I want to know if there's an official function or better ways to do it.

Thanks
what a lovely night it is
Ylaric is offline   Reply With Quote
Old 4 Weeks Ago   #692
Miffylin
Junior Member
 
White Belt
Join Date: Sep 2012



Hey Toribash community,

I am trying to create communication between Toribash and <insert language here> (Python for me). I have looked into luasocket, managed to get one compiled and work on standalone lua interpreter but I can not seem to be able to import it in Toribash scripts (does not look for .dll files, it seems).
I also noticed one post here which seemed related, but links do not work / did not tell how it works: http://forum.toribash.com/showthread.php?t=455871

Do you happen to know any means to get luasocket working in Toribash, or communicate with outside code via other (sensible) means?

Ultimately I am planning to control characters from Python and, you guessed it, apply the fancy derp learning on it to train characters to fight. I have created other lua code needed, based on the interesting evolver code by Siim Põder (github/toribash-evolver).

Cheers
Miffylin is offline   Reply With Quote
Old 4 Weeks Ago   #693
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,218
Clan: I am



Is there a specific reason you need to do it in Python? I'm not even entirely sure you need to communicate with the server. If you're working on AI/machine learning in the game I think all you really need is move data which you can get via the Lua functions. If you're dead set on using Python you can still connect to the server (think like Telnet) and parse move data received by the server.
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
box is offline   Reply With Quote
Old 4 Weeks Ago   #694
Miffylin
Junior Member
 
White Belt
Join Date: Sep 2012



Originally Posted by box View Post
Is there a specific reason you need to do it in Python? I'm not even entirely sure you need to communicate with the server. If you're working on AI/machine learning in the game I think all you really need is move data which you can get via the Lua functions. If you're dead set on using Python you can still connect to the server (think like Telnet) and parse move data received by the server.

Thank you for your answer!

I am not "dead set" to Python, but a) Python is the "de facto" language for AI/machine learning and b) LUA can be rather limiting in this regard, especially given I am not able to "require" anything ( and c) you could also use other languages than Python).

Could you specify what you mean by "connecting to the server"? I do not mean to connect "to a server", I just want to communicate from lua script to [the other language]. Luasocket library would allow this, but I have not been able to "require 'socket' " it in lua.

But what is this server you speak of? Do you mean connecting to the ongoing game on Toribash via some way like Telnet/SSH? Does that provide the game state and also allow controlling the character? I need to be able to do functionality like lua's "get_player_info" and "set_joint_state".

Last edited by Miffylin; 4 Weeks Ago at 04:34 PM..
Miffylin is offline   Reply With Quote
Old 4 Weeks Ago   #695
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,218
Clan: I am



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.
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
box is offline   Reply With Quote
Old 4 Weeks Ago   #696
Miffylin
Junior Member
 
White Belt
Join Date: Sep 2012



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; 4 Weeks Ago at 11:11 PM.. Reason: <24 hour edit/bump
Miffylin is offline   Reply With Quote
Old 4 Weeks Ago   #697
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,218
Clan: I am



That's all pretty interesting, what are your next steps for the project?
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
box is offline   Reply With Quote
Old 4 Weeks Ago   #698
Miffylin
Junior Member
 
White Belt
Join Date: Sep 2012



Originally Posted by box View Post
That's all pretty interesting, what are your next steps for the project?

Probably start off by trying some off-the-shelf deep reinforcement learning algorithms, since some of these have been tested with similar environments.

At the very least it would be interesting to see what kind of stuff will happen when you put two of these against each other. I really like how this has been tried in the past with Toribash (found some threads from 2008 talking about NEATs).

Also: I just now realized what a simple, plug-and-play "AI solution" for Toribash could do to the game (more botting). I think this needs some good thinking before sharing anything.
Miffylin is offline   Reply With Quote
Old 4 Weeks Ago   #699
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,218
Clan: I am



If you're interested, feel free to create a project thread here in the board to share updates and gather ideas and general talk. Several people have made attempts at AI but usually give up after a while.
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
box is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:57 AM.




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
ragdoll fighting game physics fighting game ragdoll fighting physics funmotion joints martial arts karate pc mac free game turn based game