Problem deserializing WorldEdit schematic
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
Problem deserializing WorldEdit schematic
I need to import a worldedit schematic within code. I tried worldedit.deserialize and gave it {x = 0, y = 10, z = 0}, "testWorld" but it did not work. Is there something I am missing? God bless you.
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
Re: Problem deserializing WorldEdit schematic
What do you mean by import the schematic? Do you mean that you want to load an existing schematic file or that you want to create a new schematic from the world?
"Only in Christ do we find real love, and the fullness of life. And so I invite you today to look to Christ." - St. John Paul II
Re: Problem deserializing WorldEdit schematic
Forget about worldedit's .we format, use .mts format and then you can use minetest.place_schematic() as-is, easy. For the records, worldedit can save and load .mts files too.ChristienChapman wrote: ↑Mon Aug 15, 2022 23:29I need to import a worldedit schematic within code. I tried worldedit.deserialize and gave it {x = 0, y = 10, z = 0}, "testWorld" but it did not work. Is there something I am missing? God bless you.
Otherwise if you insist on .we format, then Sokomine's Handle Schematics mod is able to load .we files and can serve as an example.
For some reason (also unknown to Sokomine according to the comments) deserialize doesn't work, so he has created a workaround using worldedit_file.load_schematic().
NOTE: this just loads the schematic into memory as a Lua table, you'll have to place it in the world manually.
Sokomine is using voxel_manip for that, but alternatively (and probably this is more suited for your use case) from that data you can create a Schematic specifier table (see the link for the required table fields) and then simply use minetest.place_schematic(). (First I've thought that .we Lua table and Schematic specifier Lua table are the same, but sadly no, so you have to iterate on the nodes returned by load_schematic() in the first table and copy them as MapNode into the second.)
Code: Select all
local nodes = worldedit_file.load_schematic(value, we_origin)
local schem
-- copy node data to a second table in MapNode format
for i = 1, #nodes do
local ent = nodes[i]
-- little magic to parse ent.x, ent.y, ent.z and insert in correct order
table.insert( schem.data, { name=ent.name, param1=..., param2=... });
end
-- add other required fields, like dimension
schem.size = { width, height, depth }
return schem
Hope this helps,
bzt
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
Re: Problem deserializing WorldEdit schematic
Thanks
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
Who is online
Users browsing this forum: No registered users and 12 guests