-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
place_schematic places old(outdated) schematic even if schematic file got updated #4236
Comments
Is this behavior unexpected...? I think it's pretty clear from the documentation that this is supposed to happen. |
kwolekr coded the schematic code. |
If I call place_schematic filename, I would expect that it places that schematic saved in filename and not something old. @kwolekr I cant find documentation about this behaviour. It is not noted in lua_api.txt:
|
It is not related to worldedit. I used the Worldedit commands only as example, how to reproduce this behaviour. The bug occur also in my Gates mod, and makes it nearly unusable. EDIT: Every mod that uses create_schematic and place schematic is affected by this.
and
so param 2 At least I would expect the same behaviour as in Minetest 0.4.13 where it worked correct. |
Could it be that when 'test' is saved the second time it is a duplicate so gets a filename like 'test.2' or something, then placing 'test' grabs the first version? |
Relevant: https://github.com/minetest/minetest/blob/master/src/script/lua_api/l_mapgen.cpp#L1282 This code is optimized to assume that schematics won't change, so that it doesn't need to re-read the schematic from file thousands of times, which would kill mapgen placement of schematics. Changing schematics is fine, just don't save them to a file, instead, maintain them in a lua table. I think that should just work - reading the code it appears that if you pass a lua table, it will use the contents of the table each time. |
My current assessment that this is expected behavior, and therefore not a bug. The documentation could be updated to reflect this behavior. If you want to change schematics at run time, you can read the schematic manually from file yourself, and pass the schematic as table to |
@kwolekr I couldn't find a place where the doc says this. Can you point to it? |
Its bad if somebody can't reload a schematic from a file, just because earlier in the execution that schematic has already been loaded once. Loading to a table is not a good solution as it is slower. There is lots of abstractions going on with ids being returned that can be re-used. So either we let schematic code reload the file each time it is used as file, and ask mod developers to use schematic ids to speed up, or we add special schematic specifiers e.g. of the form I do not think that its a good idea to have inconsistencies in API behaviour where different functions reload schematic files and others use the pre-cached value. Its against this "schematic specifier" abstraction idea by making things more complicated. |
If the schematic is cached, then there is already a map filename --> cache, right? |
Hi. Still, there is an use case for loading the schematic again from the same file. The use case are schematic editing tools so there's a quick way to load a schematic and test a newly created schematic. I like the previous suggestion with simply adding an optional |
Unfortunately beyond my ability to code this, anyone interested? |
The replacements parameter is also cached. It is not possible to place the same schematic twice with diffrent replacements without shutting the world down and starting anew. Caching is reasonable for schematics used as decoration for mapgens. The trouble is: The behaviour is not documented. The main documentation, lua_api.txt, needs to be updated now to reflect how the api function works - not when this problem as such has been solved finally in the future. Instead of an additional parameter to force-reload the schematic without cache, it would also be possible to offer a function - i.e. minetest.discard_schematic( filename ) or minetest.forget_schematic( filename ) or something like that - that just removes the cached data for that particular filename. Maybe that is easier to implement. |
PR #6889 merged. Docs now describe the behaviour. |
Now documented so any core dev support for the suggestions? |
Documentation does not solve the problem that the cached schematic cannot be reset in Lua. |
Yeah i know :) If you support the suggested feature do remove 'possible close'. |
I hope this limitation can be solved and a way to reset the cached schematic implemented. This will be problematic for my Structures mod, which relies on the ability to design buildings then import / export them freely each to their own file. If it isn't I'll have to attach date strings to each schematic's file name which will be a lot more messy in my opinion. In the meantime it looks like this might have broken importing a schematic more than once at all: As described in #8106 I can only call minetest.place_schematic once per session, after that I get a "failed to get schematic" error. |
minetest.create_schematic updates the old schematic file, but minetest.place_schematic places the old shematic
Reproducible with stable Minetest 0.4.14 on Windows 7 (single player) and on Debian (server)
Easiest way to reproduce is using worldedit, but each other mod that uses create- and place_schematic works.
Note: It places the schematic file created in step 5 if you don't execute step 3.
from debug.txt:
The text was updated successfully, but these errors were encountered: