Minetest logo

IRC log for #minetest-mods, 2014-09-29

| Channels | #minetest-mods index | Today | | Google Search | Plaintext

All times shown according to UTC.

Time Nick Message
00:00 Zefram_Fysh so you can have the server listen to stdin alongside the network
00:00 Zefram_Fysh and adding a game mod is the wrong way to approach your objective
00:00 zatherz if the server is running in a single thread
00:00 zatherz how could I write to stdin so that it would read it?
00:01 Zefram_Fysh you write in the normal way.  maybe you meant to ask how the server can read it?
00:01 zatherz oh, I've found a Lua script for management of FIFOs
00:02 Zefram_Fysh polling repeatedly, which is what you'd do from lua, is the wrong way to do it
00:03 zatherz so, let's go back to what I should do
00:03 Zefram_Fysh you want the server's select() loop to include stdin as a filehandle of interest
00:03 zatherz 1. Add code in server for reading of FIFO/stdin
00:04 zatherz 2. Constantly read from FIFO/stdin and if not empty, send server command
00:04 zatherz (in server code)
00:04 zatherz 3. Start server from my application
00:05 zatherz 4. Start Minetest with commandline opts to connect to the server
00:05 zatherz is that right?
00:06 Zefram_Fysh anything involving "constantly read" is dubious.  by the magic of select(), you should only be reading from stdin when there is something there to read
00:06 Zefram_Fysh if you don't understand select(), go and read up on it first
00:06 zatherz in the server protocol?
00:06 zatherz or in C++?
00:07 zatherz (by C++ I mean standard libs)
00:08 Zefram_Fysh it's a system call, select(2)
00:08 zatherz yeah, that's what I meant in second one
00:09 Zefram_Fysh so it's in libc, but it's not part of the C or C++ standard library as defined by the language standards
00:09 Zefram_Fysh it's part of Unix standards
00:09 zatherz yeah, wrongly worded, sorry
00:13 zatherz any way to do that crossplatform?
00:15 zatherz meh
00:16 zatherz I'm going to do what I wanted at first
00:16 Zefram_Fysh since the server already uses it, that shouldn't be a big worry.  IIRC, Windows has a limited version of select() that only works on sockets, which would screw up using stdin, so you might need to jump through more hoops specifically for Windows
00:16 zatherz that is, a simple file being read by a simple mod
00:16 zatherz coming with a simple API for controllng this simple file
00:16 zatherz *controlling
00:17 Zefram_Fysh your problem here consists mainly of you not understanding the IPC mechanisms that are available.  hacking up something using the wrong primitive (a regular file) doesn't solve your problem
00:17 zatherz not "hacking up"
00:17 zatherz it's a mod that just executes commands from a file
00:18 ShadowNinja zatherz: Such a mod already exists.
00:18 zatherz I know.
00:18 Zefram_Fysh if you were executing a file of commands once at startup then it would be that simple.  it would also be redundant with the mod mechanism itself
00:18 ShadowNinja I have one installed on my server.  It's significantly different (and better) than the original one by Menche though.
00:19 zatherz I generally prefer writing my own code
00:19 Zefram_Fysh you've described wanting to send new commands intermittently while the server is running.  that is not a problem that a regular file addresses well
00:19 zatherz unless I have problems with writing it
00:19 ShadowNinja zatherz: Annother option is using a named pipe or unix domain socket, but that requires external libs and depends on *nix.
00:19 Zefram_Fysh if you go this route, you're going to end up with crap
00:19 zatherz Shadow: exactly the thing I want to prevent
00:19 zatherz Shadow: I personally use Linux
00:20 zatherz Shadow: but I did not use Qt libs for GUI just to make it work on only one platform
00:21 ShadowNinja zatherz: Here's my version, it also makes a chat log: http://sprunge.us/TZge?lua
00:21 petrusd987 joined #minetest-mods
00:21 ShadowNinja Ought to be helpfull at least, even if you write your own.
00:23 zatherz nice
00:24 zatherz oh
00:24 zatherz thanks actually
00:24 zatherz now I know register_globalstep is the way to get it running in a kind of loop
00:25 zatherz from the name, I'd never guess it
00:25 Zefram_Fysh that's the wrong way to do it
00:26 zatherz Zefram: yes, of course, an API function made specifically for calling it every server step is not the way to get a function to be called every server step
00:26 zatherz Zefram: seems legit
00:26 ShadowNinja Zefram_Fysh: It's a little hacky, but it's simple and it works.
00:26 Zefram_Fysh executing your code every server step is the wrong way to accept intermittent input
00:27 ShadowNinja zatherz: Note, you can use a counter variable to make it run only once every X steps.  That code will process multiple lines so you can change it to 100 steps or so (there are usually 10 steps/sec).
00:28 zatherz Shadow: yeah, I'm looking at your code and at the dev wiki
00:28 ShadowNinja It'll cause fewer wasted CPU cycles, but will add a delay.
00:28 zatherz I can make it configurable too
00:29 zatherz like, /exec 10
00:29 zatherz for 10 seconds of delay
00:30 ShadowNinja zatherz: Yes, you can, but that'll over-complicate it IMO.
00:31 zatherz yeah
00:31 zatherz I just need to run commands from my application
00:31 zatherz and interval doesn't have to be configurable
00:35 zatherz thank you Zefram and Shadow
00:46 Taoki joined #minetest-mods
02:31 Miner_48er joined #minetest-mods
03:39 Miner_48er joined #minetest-mods
04:56 zatherz joined #minetest-mods
07:53 petrusd987 joined #minetest-mods
12:50 PilzAdam joined #minetest-mods
13:08 phantombeta joined #minetest-mods
14:42 GrimKriegor joined #minetest-mods
15:17 Wuzzy joined #minetest-mods
15:39 jin_xi joined #minetest-mods
15:49 Wuzzy2 joined #minetest-mods
16:36 rubenwardy joined #minetest-mods
17:10 Taoki Hi. What was the function to check if a node is solid, or liquid, and so on? IIRC there was a function like that... or you could check group:solid or something
17:43 Zefram_Fysh there is no group.  you're probably thinking of the "walkable" property (in the node type definition)
17:44 Zefram_Fysh and "liquidtype" for liquidness
17:55 PilzAdam Taoki, minetest.registered_nodes["foo:bar"].walkable
19:00 Taoki Back. Thanks PA
19:09 rubenwardy joined #minetest-mods
19:26 phantombeta joined #minetest-mods
19:37 Miner_48er joined #minetest-mods
20:27 LazyJ joined #minetest-mods
22:07 ShadowNinja Taoki: Note: Make sure you account for unknown nodes.  They're a big source of crash bugs.
22:07 Taoki https://forum.minetest.net/viewtopic.php?f=11&t=9240&p=156177#p156177 New feature in Creatures mod. Mobs can now take objective nodes, and walk to or avoid various nodes based on light level even. Check it out if anyone's interested :)
22:07 Taoki ShadowNinja: ok
22:07 ShadowNinja (they aren't in minetest.registered_*)
23:28 Miner_48er joined #minetest-mods
23:32 phantombeta joined #minetest-mods

| Channels | #minetest-mods index | Today | | Google Search | Plaintext