Time Nick Message 12:28 ireallyhateirc Are additions to the built-in lua vectors welcome? For example I made my own vector.ceil (that's missing) and vector.random 12:29 ireallyhateirc these aren't hard to make yourself but I guess it's better to spend your time on actually making games/mods rather than writing basic utilities 12:41 MTDiscord ireallyhateirc: if these abstractions are pretty much universally useful, i'd say they are welcome, yes. vector.ceil is just vector.apply(math.ceil) though, and vector.random has some potential for bikeshedding... 12:45 ireallyhateirc lua's math provides math.ceil so I guess it's only natural to expect vector.ceil 12:45 ireallyhateirc no matter how trivial the implementation 12:45 ireallyhateirc Here's my vector.random: 12:46 ireallyhateirc function vector.random(...) 12:46 ireallyhateirc return vector.new(math.random(...), math.random(...), math.random(...)) 12:46 ireallyhateirc end 12:49 MTDiscord I'd be tempted to just implement function vector.create(f, ...) return vector.new(f(...), f(...), f(...)) end instead 12:49 MTDiscord then vector.random would be just vector.create(math.random) 12:50 ireallyhateirc yeah, that's more universal than vector.apply 12:50 MTDiscord ireallyhateirc: it's different 12:51 MTDiscord vector.apply takes an existing vector and applies a function to it, this function creates a vector given a function to call with the same arguments for each coordinate 12:51 ireallyhateirc yeah 12:53 ireallyhateirc Just wonder if there's a better name than .create which is kind of ambiguous (similar to .new) 12:54 ireallyhateirc but I guess this shouldn't be a big problem if documented properly 12:54 ireallyhateirc vector.create_with_function would be more descriptive but also long 12:57 MTDiscord ireallyhateirc: i didn't think too hard about the name, but bear in mind that the context will make it pretty clear that it takes a function - for example if you see vector.create(math.random) 12:59 ireallyhateirc yeah, it should be fine then 13:03 ireallyhateirc I'm also thinking about handling functions that return multiple values in vector.apply 13:04 ireallyhateirc for example there's the math.modf and I wrote my own vector.modf 13:04 ireallyhateirc https://codeberg.org/lord_of_the_dumpster/perfect_city/src/commit/fccbfa19df1193b825c5b9db23bafe2b55dcc3e1/mods/pcity_mapgen/utils.lua#L185 13:05 ireallyhateirc this sounds a little dangerous though, because some functions can return values that are not numbers 13:05 ireallyhateirc it could probably also make functions that use vector.apply a little slower 16:17 nekobit Hi, are there any useful methods for debugging mods/games? 16:18 nekobit Restarting the world over and over gets tedious, but i have thought about making a --go while loop which quickly reselects the world 16:22 ireallyhateirc depending on what you debug/test you may want a fresh world or the old world so I doubt you can make any "one fits all" solution 16:22 ireallyhateirc though I'd like to be proven wrong because it is indeed tedious 16:26 nekobit One of the greatest things about dynamic programming languages is that you can do dynamic things with it 16:39 ireallyhateirc fair 18:16 MTDiscord nekobit: --world and --go together allows for a pretty fast workflow if your game starts up fast enough: up arrow, enter, test, exit, rinse and repeat 18:16 nekobit i have it set to a sh while loop 18:17 nekobit however live reloading would be very convenient 18:17 MTDiscord for specific stuff, you could implement hot reloading, or use existing things like https://content.minetest.net/packages/Just_Visiting/formspec_editor/ 18:28 nekobit Ta 18:52 MTDiscord you could use inotify to listen for save events, and restart a minetest process 18:56 Krock read an environment variable within the main menu and auto-join a specific world 18:57 Krock (overcomplicated solution for what's already implemented differently) 19:34 nekobit wsor4935: That's true 23:32 BluebirdGrey51 Quick question, according to Lua docs I can transfer a VoxelManip into MT's async environment. Can I transfer it OUT? Example: huge tnt boom: on main thread, get voxelmanip, transfer to async. On async, compute all the tnt stuff, map changes, etc. Transfer to main thread. On main thread: apply voxelmanip to real map. Possible? 23:35 BluebirdGrey51 Other example: large fortress/dungeon generation 23:35 ireallyhateirc Haven't tried it, but api doc says this: minetest.handle_async(func, callback, ...): 23:35 ireallyhateirc "When func returns the callback is called (in the normal environment) with all of the return values as arguments." 23:35 MTDiscord bluebird: you would probably want to use 5.9 async mapgen api 23:36 ireallyhateirc not sure if mapgen environment would work for stuff like TNT? 23:36 BluebirdGrey51 I'm using the 5.9 async mapgen already, but so far only for mapgenning new chunks. No idea how I could "rerun" it for tnt/fortress stuff? 23:37 ireallyhateirc we will have this in the future: https://github.com/minetest/minetest/pull/14659 23:38 ireallyhateirc but again, for ordinary asynch envs I guess you can use the callback from minetest.handle_async 23:39 ireallyhateirc so I believe the callback just handles stuff returned by the function ran in the asynch env? 23:39 MTDiscord you could also delete the area so it regenerates. assuming there is nothing of value there 23:39 BluebirdGrey51 Yes, about the callback is what I am wondering: would it be able to receive the voxelmanip after the async thread was done with it. 23:40 BluebirdGrey51 Area deletion is definitely not an option 23:40 ireallyhateirc if not the voxelmanip object, you can still pass a copy of the (possibly outdated) flat array 23:40 MTDiscord minetest.handle_async(func, callback, ...) -> When func returns the callback is called (in the normal environment) with all of the return values as arguments. 23:40 MTDiscord read the docs? 23:41 ireallyhateirc wsor4035, I just quoted this above 23:41 BluebirdGrey51 Yes, but the docs also talk about serialization for parameters passed IN. If parameters passed out are also serialized, I don't know what this would do to the voxelmanip. I guess I could code up a test ... 23:43 ireallyhateirc keep in mind that VM data can get outdated quickly 23:43 ireallyhateirc so you probably need to calculate a diff 23:44 ireallyhateirc or trust the data as is and hope you won't remove stuff players just did lol 23:45 ireallyhateirc is your TNT example a real one? What's the average time needed for your VM operation? 23:45 BluebirdGrey51 the tnt example is just an example, my real usecase is fortress generation (these can get up to 200 nodes in length/width). 23:46 BluebirdGrey51 The fortresses are only supposed to generate at mapgen time, but for obvious reasons I can't do it on the mapgen thread. 23:46 BluebirdGrey51 The mapchunks are too small. 23:46 BluebirdGrey51 Though, even with TNT, a large explosion on my server, in the right location, can lag for up to 5 seconds. 23:46 ireallyhateirc BluebirdGrey51, this shouldn't be a problem 23:46 MTDiscord or just break up your structure across chunks? see other mods for this 23:47 ireallyhateirc mapgen does 1 mapchunk + mapblock margin 23:47 ireallyhateirc so if you divide your structure into smaller parts that fit inside, you should be safe 23:48 ireallyhateirc alternatively you can write some wicked overgeneration code like I did for my road generation in my Perfect City game 23:49 BluebirdGrey51 If I understand rightly how it works, overgeneration is not possible on the mapgen thread, only on the main thread? 23:49 BluebirdGrey51 At least IIRC the doc had some kind of warning. .. 23:50 BluebirdGrey51 (I mean, overgeneration beyond the usual overgenerate margin) 23:51 ireallyhateirc your fortress thing - is it a schematic or? 23:52 BluebirdGrey51 it's a collection of schematics, which get combined together to form a fortress. 23:53 ireallyhateirc if you divide the structure into pieces no bigger than a mapchunk and align the structure to the mapchunk grid, they you don't need overgeneration 23:53 BluebirdGrey51 Generating it is basically 2 steps: 1) design the fortress, and create a huge table with all the layout info. 2) apply all the schematics to the voxelmanip using the data. 23:54 BluebirdGrey51 Step 1 uses a pseudo random algorithm. 23:54 ireallyhateirc you can do your own overgeneration if you get adjacent mapchunks and spawn the structure also in the adjacent chunks 23:56 ireallyhateirc so you need a list of mapchunks that contain your module/prefab (for example a cube) 23:56 ireallyhateirc then you need the absolute position where the module is placed 23:56 ireallyhateirc and then you simply place the structure in the chunks 23:58 ireallyhateirc Do you understand this or do you want me to draw it for you in GIMP? 23:58 BluebirdGrey51 So, it sounds like my step 1 (the pseudo random algorithm) would need to use a seed number to produce exact results from one mapchunk to the next. 23:58 ireallyhateirc yes, you need to make it reproducible 23:59 BluebirdGrey51 Gotcha. 23:59 ireallyhateirc use a randomseed that doesn't depend on blockseed or whatever the thing is 23:59 ireallyhateirc I solved a similar problem here: https://codeberg.org/lord_of_the_dumpster/perfect_city/src/branch/master/mods/pcity_mapgen 23:59 ireallyhateirc though it's a big blob of code that's not yet documented well