Post your modding questions here

User avatar
Ben
Member
 
Posts: 157
Joined: Tue Mar 31, 2015 20:09

Re: Post your modding questions here

by Ben » Fri Oct 23, 2015 20:51

Ferk wrote:About the distance calculation, perhaps the best is to use vector.distance(p1, p2)


I just looked up vector.distance: it's still implemented in Lua, and calls math.hypot twice. I've got a mind to make a pull request for vector.distance2 or similar. But that would be premature optimization ;-P

Ferk wrote:
Ben wrote:in my experience, CPU is "free" nowadays

My i7 processor roars like a tiger when playing pacman


Yeah, I should have qualified my remark a bit: I code websites for a living, where anything done in-process is practically invisible when compared to I/O :-P
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Sat Oct 24, 2015 12:35

Ferk wrote:Doesn't the engine already handle that? I mean.. how does it know a player can't go forward if there's a wall in front? or how does it know you are touching fire and should get damaged? I guess the server checks for collisions.
Or do you mean that that's client side? Even the damage_per_second?

Perhaps the problem is that the lua api is on a different, higher, level. Maybe some structural problem doesn't let them expose the collision logic to lua or they can't access the node definitions table. But I don't think the problem is overhead for checking the collisions.


Collision detection is indeed client side, that's exactly how hacked clients can get fly/no-clip on servers. Maybe someday this sort of thing will be possible with client-side modding, meanwhile the polling approach (however you trigger it) is really the only way you can do it
 

User avatar
Ferk
Member
 
Posts: 330
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: Post your modding questions here

by Ferk » Sat Oct 24, 2015 13:00

stu wrote:Collision detection is indeed client side, that's exactly how hacked clients can get fly/no-clip on servers. Maybe someday this sort of thing will be possible with client-side modding

I see, thanks, I understand now. I thought Minetest already was preventing cheating at that level.

Personally, I can accept giving up on cheat prevention on some levels. I think it's a trade-off, I'd rather have a fun game with many possibilities powered by client-side algorithms than a limited game full of bugs caused by the lag because of being afraid of the players cheating. I don't think Minetest is intended for any sort of professional cheat-protected tournament anyway. So I'd be happy to use client side APIs when available.

meanwhile the polling approach (however you trigger it) is really the only way you can do it

If this is really what everyone is using and / or people think it's worth it to do it in the server rather than the client, then maybe it would make sense to actually have either a "standard" lua library (or mod) to do it that can be peer reviewed and improved, or actually added to the engine as a server side check that only runs the polling whenever it makes sense. I guess there are ways in which this could be further optimized, even if it wasn't done using the client-side physics engine. Perhaps having a centralized system for it would help, so that we only iterate over the list of players once.
Last edited by Ferk on Sat Oct 24, 2015 13:24, edited 1 time in total.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Sat Oct 24, 2015 13:23

Ferk wrote:I see, thanks, I understand now. I thought Minetest already was preventing cheating at that level.

Personally, I can accept giving up on cheat prevention on some levels. I think it's a trade-off, I'd rather have a fun game with many possibilities powered by client-side algorithms than a limited game full of bugs caused by the lag because of being afraid of the players cheating. I don't think Minetest is intended for any sort of professional cheat-protected tournament anyway. So I'd be happy to use client side APIs when available.


Yes, of course there are anti-cheat mechanisms you can enable but I don't think that cheating is really that big of a problem. This is pretty much how all games of this nature work and it's just down to good server moderation to remove/ban any cheaters.

One possibility for your pacman game would be make it so that you have to dig the pips in order to move, not ideal I admit though it would save you a lot of problems.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sat Oct 24, 2015 13:50

We don't want to dig the pips. We want it like the original where you walk past it and it gets eaten.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sat Oct 24, 2015 16:08

Don wrote:We don't want to dig the pips. We want it like the original where you walk past it and it gets eaten.


I scrolled back a bit and couldn't find any context for this, other than it's pacman.

Couldn't you just modify the pick up code from PilzAdam's mod? So when you run over a pip entity, it is sucked up.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sat Oct 24, 2015 16:18

rubenwardy wrote:
Don wrote:We don't want to dig the pips. We want it like the original where you walk past it and it gets eaten.


I scrolled back a bit and couldn't find any context for this, other than it's pacman.

Couldn't you just modify the pick up code from PilzAdam's mod? So when you run over a pip entity, it is sucked up.

Look upa few posts to stu. His last paragraph.

The pips are nodes. The pacman pellets. Ferk has them working good but would work better if there was an on_collision function.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
Ferk
Member
 
Posts: 330
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: Post your modding questions here

by Ferk » Sat Oct 24, 2015 16:25

Yes, we are working together on the pacman mod.
I just checked PlizAdam's mod (I guess this one: https://github.com/PilzAdam/item_drop )

He uses a globalstep, along with get_objects_inside_radius. The pellets are nodes not object. If they were objects it might not work that well since there are more than 200 of them and they will probably constantly get loaded/unloaded.

The node "equivalent" function find_node_near has other problems, I mentioned that some comments above. It only returns positions so I ahve to either call it multiple times (once for each type of item to collect.. like the powerup or the fruits) or I'll have to do a get_node anyway for each of the nodes it finds.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Sat Oct 24, 2015 18:20

My trail mod has code for changing nodes walked on, it's not very lightweight though, but reasonable https://github.com/paramat/trail
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Sat Oct 24, 2015 18:39

Don wrote:We don't want to dig the pips. We want it like the original where you walk past it and it gets eaten.

I like the idea of a pacman mod so I thought I would give something a quick try.

This idea uses the lua voxel manipulator so the maze position must be known in advance (pmin, pmax)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local timer = 0

minetest.register_node("pacman:pip", {
   description = "Pacman Pip",
   tiles = {"pacman_pip.png"},
   walkable = false,
   on_collision = function(pos)
      minetest.remove_node(pos)
   end,
})

minetest.register_globalstep(function(dtime)
   timer = timer + dtime
   if timer > 0.1 then
      local pmin = {x=-20, y=0, z=-20}
      local pmax = {x=20, y=0, z=20}
      local vm = VoxelManip(pmin, pmax)
      for _,player in ipairs(minetest.get_connected_players()) do
         local pos = player:getpos()
         local node = vm:get_node_at(pos)
         local ref = minetest.registered_nodes[node.name]
         if type(ref.on_collision) == "function" then
            ref.on_collision(vector.round(pos))
         end
      end
      timer = 0
   end
end)


In this example I have given the nodes an on_collision callback but the removal could also be done directly using the vm.
I have no idea how well this would perform on a public server but it seems to work ok in singleplayer, even on my crappy old pc :/

Building on this idea, I guess you could do away with the vm and simply use a pre-defined array of pip locations. This way you only need to check if a player's current position matches one of the known pip locations which I reckon you can safely do on every server step.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
pacman = {
   pips = {},
}

minetest.register_node("pacman:pip", {
   description = "Pacman Pip",
   tiles = {"pacman_pip.png"},
   walkable = false,
})

minetest.register_abm({
   nodenames = {"pacman:pip"},
   interval = 1.0,
   chance = 1,
   action = function(pos, node)
      local id = minetest.hash_node_position(pos)
      pacman.pips[id] = 1
   end,
})

minetest.register_globalstep(function(dtime)
   for _,player in ipairs(minetest.get_connected_players()) do
      local pos = vector.round(player:getpos())
      local id = minetest.hash_node_position(pos)
      if pacman.pips[id] then
         minetest.remove_node(pos)
         pacman.pips[id] = nil
      end
   end
end)
 

User avatar
Ferk
Member
 
Posts: 330
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: Post your modding questions here

by Ferk » Sat Oct 24, 2015 21:27

Isn't allocating a new vm each cycle too much if you just want to check one or two nodes per step? We actually have already a working pacman that works ok in singleplayer. it's just that the discussion about the on_collision has been dragged for a few days in this thread :P ..it didn't even start with pacman.

use a pre-defined array of pip locations. This way you only need to check if a player's current position matches one of the known pip locations which I reckon you can safely do on every server step

That's clever, it would probably be much faster. We still have to test the game in a remote server, though, maybe the current approach is already enough, but that would be an interesting alternative.

Btw, what if I kept the same voxelmanip around and reused it in the globalstep? Does the vm keep the list of nodes in memory so it wouldn't need to poll the map every time and work pretty much like the list of pips in your second idea? It would use some more memory but then it doesn't need an abm.

I'm now writing some api to keep a list of highscores. The idea is actually to make a modpack with different arcade games. Hopefully pacman would be the first of many.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

minetestcr
Member
 
Posts: 57
Joined: Fri Feb 13, 2015 21:31

Re: Post your modding questions here

by minetestcr » Sun Oct 25, 2015 02:47

Hello. How can I make a node that lays flat on the node face it is placed? like the ladder in the image:
http://pasteboard.co/1D4bL4Lm.png
Image
thanks!
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sun Oct 25, 2015 03:28

minetestcr wrote:Hello. How can I make a node that lays flat on the node face it is placed? like the ladder in the image:
http://pasteboard.co/1D4bL4Lm.png
Image
thanks!

Add this to your node def

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
on_place = minetest.rotate_node
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

minetestcr
Member
 
Posts: 57
Joined: Fri Feb 13, 2015 21:31

Re: Post your modding questions here

by minetestcr » Sun Oct 25, 2015 03:43

Don wrote:Add this to your node def

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
on_place = minetest.rotate_node


thanks Don... I tried, but I'm doing something wrong, I added the code like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
   minetest.register_node("stj:laminaverde", {
   description = "lámina verde",
   tiles = {
      "paredverde.png",
      "paredverde.png",
      "paredverde.png",
      "paredverde.png",
      "paredverde.png",
      "paredverde.png"
   },
   drawtype = "nodebox",
   paramtype = "light",
   on_place = minetest.rotate_node,
   material = minetest.digprop_constanttime(1.0),
   groups = {snappy=3,cracky=3,oddly_breakable_by_hand=3,},
   node_box = {
      type = "fixed",
      fixed = {
         {-0.5, -0.5, 0.4375, 0.5, 0.5, 0.5}, -- NodeBox1
      }
   }
})
   }
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sun Oct 25, 2015 04:25

You need paramtype2 set

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
paramtype2 = "facedir",
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

minetestcr
Member
 
Posts: 57
Joined: Fri Feb 13, 2015 21:31

Re: Post your modding questions here

by minetestcr » Sun Oct 25, 2015 04:58

Don wrote:You need paramtype2 set

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
paramtype2 = "facedir",


thanks, that's it
 

DoyleChris
Member
 
Posts: 176
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: Post your modding questions here

by DoyleChris » Tue Oct 27, 2015 22:40

Is there a way with Mesecons or DIgilines to have a counter. Example I have a chest where all my Iron Lumps go into. And i want to use a Stack Injector to send a full Stack to a grinder, Then output it to a tube dectector which sends a signal to the counter till it reaches 198 then sends a signal to the injector to send a new stack to the grinder.
 

Soudon
Member
 
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

Re: Post your modding questions here

by Soudon » Wed Oct 28, 2015 18:09

Working on a survivial sub game I have the survival mod but I would like to know how to go about adding a temperature gauge/ in snow biomes you get cold being wet you get cold etc and need to have a campfire or some source of fire to dry off/warm up. And if you get too cold you can die from it.
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Thu Oct 29, 2015 10:23

Hi,

I'm playing around with the minetest.register_on_generated function and I'm stuck with a problem I can 't explain. It is probably some stupid oversight from me, but if anyone can shed some light on it, I'd appreciate it.

I include my cut-down code here, I stripped out as much as possible (like the random x/z coordinates and the calculation of floorlevel,...) and left the bare minimum. What it does (or should do) is put a schematic on the map and tell me by chatmessage where it is. However in most cases it doesn't get placed on the map, and sometimes (very rarely) it does. The schematic file exists at that location on my disk and is not corrupt (I can manually place the schematic from within minetest).

If i remove the place_schematic line and put in some minetest.add_node(next_tower, { name="default:mossycobble"}) lines, these appear without any problems.

I'm now going to check out the minetest.register_decoration function, maybe this is better suited for what I want, but I find it strange that place_schematic doesn't seem to work in the register_on_generated.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
      local debugmessage = ""
      -- don't build towers above 80 or below -10
      if (maxp.y > 80) then return end
      if (maxp.y < -10) then return end

      -- initialize the position of the tower
      local next_tower = {
            x = minp.x + 20,
            y = 20,
            z = minp.z + 20,
      }
         debugmessage = debugmessage .. " drawing tower " .. next_tower.x .. ", " .. next_tower.y .. ", " .. next_tower.z
         minetest.chat_send_all(debugmessage)
         -- put the tower on the map
         minetest.place_schematic(next_tower, "/home/afeys/.minetest/mods/afmodpack/treasuretowers3/schems/ttower1.mts" , rotation)

end)


Added info: if I do a minetest.add_node(next_tower,......) BEFORE i do the place_schematic, then the schematic is shown correctly. Anyone have any ideas what's going on?
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Fri Oct 30, 2015 09:50

afeys wrote:Hi,
Added info: if I do a minetest.add_node(next_tower,......) BEFORE i do the place_schematic, then the schematic is shown correctly. Anyone have any ideas what's going on?


This was apparently a coincidence.. Still have the same problem.
I wrote some code to 'empty' (using remove_node) the necessary space on the map before doing the place_schematic. The place gets cleared but no schematic is added to the map. (in most cases)

Is there an alternative to place_schematic that does work in the register_on_generated ? Or does a tool exists which converts schematic files into the appropriate set_node commands which I can then copy/paste into my lua code?
 

User avatar
Ferk
Member
 
Posts: 330
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: Post your modding questions here

by Ferk » Fri Oct 30, 2015 10:03

There's no reason that I know of that could prevent place_schematic from getting called from on_generated.. I do use it to spawn the dungeon entrances in dungeontest with no problems.. (I was using a spawning abm before, but changed it to remove the "poping up" effect and it seems to work fine). Depending on the chunksize you might have some problems, but not getting anything placed at all is weird.

Maybe you could try changing your chunksize setting and see if it has any repercusions. I think chunks start at -32,-32,-32 (correct me if I'm wrong) and are set by default to be 80 nodes wide (5 blocks of 16 nodes) in all directions. This means the chunk ends at y=45, I guess your tower is taller than that, specially if you are placing it already in y=20

Perhaps your safest bet is to use a placer node with an abm to place the schematic. Even though this would make the building "pop up" to existence when the player walks in.

does a tool exists which converts schematic files into the appropriate set_node commands which I can then copy/paste into my lua code?

The closest thing to that is probably worldedit. It has also the benefit that it will save the metadata as well. The drawback is that it's slower than native place_schematics, and you'll have to include worldedit in your modpack.

How big is your tower? I've also had problems when trying to get the Tutorial world from Wuzzy generated using mts.. it works fine if I use worledit files but mts don't seem to get saved properly at times, specially if it's big. My tutorial world mts was like only 1 KB in size when saved even though it was a big area, and crashed when I tried to place it. But it seems it's not the same problem you had.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Fri Oct 30, 2015 11:36

Thanks for the reply, Ferk.

Ferk wrote:Maybe you could try changing your chunksize setting and see if it has any repercusions. I think chunks start at -32,-32,-32 (correct me if I'm wrong) and are set by default to be 80 nodes wide (5 blocks of 16 nodes) in all directions. This means the chunk ends at y=45, I guess your tower is taller than that, specially if you are placing it already in y=20

That seems like a plausible reason. I'll try again with a much smaller mts file this weekend. Maybe split the tower up in separate mts files per floor or something. I'll see what that does. My tower is 3 floors and a roof, but that could easily be too much according to your explanation.
What is weird though: I have a draw_box function (see below) which draws a 3-D outline (for debugging purposes) around the area where the tower is supposed to be, and that works perfectly, even if the mts file itself isn't shown !

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
treasuretowers_draw_box = function(start_pos, end_pos, drawblock)
local inc_x = 1
local inc_y = 1
local inc_z = 1
local blockpos = start_pos
if (start_pos.x > end_pos.x) then
   inc_x = -1
end
if (start_pos.y > end_pos.y) then
   inc_y = -1
end
if (start_pos.z > end_pos.z) then
   inc_z = -1
end
for i= start_pos.x, end_pos.x, inc_x do
   blockpos = {x=i, y=start_pos.y, z=start_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=i, y=start_pos.y, z=end_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=i, y=end_pos.y, z=start_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=i, y=end_pos.y, z=end_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
end
for i= start_pos.y, end_pos.y, inc_y do
   blockpos = {x=start_pos.x, y=i, z=start_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=start_pos.x, y=i, z=end_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=end_pos.x, y=i, z=start_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=end_pos.x, y=i, z=end_pos.z}
   minetest.add_node(blockpos, { name=drawblock})
end
for i= start_pos.z, end_pos.z, inc_z do
   blockpos = {x=start_pos.x, y=start_pos.y, z=i}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=start_pos.x, y=end_pos.y, z=i}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=end_pos.x, y=start_pos.y, z=i}
   minetest.add_node(blockpos, { name=drawblock})
   blockpos = {x=end_pos.x, y=end_pos.y, z=i}
   minetest.add_node(blockpos, { name=drawblock})
end

end


Ferk wrote:Perhaps your safest bet is to use a placer node with an abm to place the schematic. Even though this would make the building "pop up" to existence when the player walks in.

Yep, that was my previous approach and it worked perfectly. I had defined a rare ore which spawns in dirt_with_grass blocks and then an abm to replace that block with my tower.
The "pop up" effect was really annoying, even after I added some particles to simulate a 'magic' effect.

Ferk wrote:How big is your tower? I've also had problems when trying to get the Tutorial world from Wuzzy generated using mts.. it works fine if I use worledit files but mts don't seem to get saved properly at times, specially if it's big. My tutorial world mts was like only 1 KB in size when saved even though it was a big area, and crashed when I tried to place it. But it seems it's not the same problem you had.


I started with a rather small tower, the file is 736 bytes. dimensions are 13x13 and 20 high.
Maybe I'll write a function which processes the .we fileformat and uses set_node to build my tower.


Edit:
I've tried it with a small 3x3x2 mts file and have the same problem. I'm dumping mts files, and going to write a .we drawing function. I'll have a look at WorldEdit and see how they do it.
 

User avatar
firefox
Member
 
Posts: 1185
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox

Re: Post your modding questions here

by firefox » Fri Oct 30, 2015 12:22

Lord of the Test has buildings in the mapgen (some of them are quite large).
they are all saved as .we files i guess the game also use worldedit to place them on the map.

maybe that helps...
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Fri Oct 30, 2015 12:24

firefox wrote:Lord of the Test has buildings in the mapgen (some of them are quite large).
they are all saved as .we files i guess the game also use worldedit to place them on the map.

maybe that helps...


Thanks for the info, firefox. I'll have a look at their code.
 

User avatar
Ferk
Member
 
Posts: 330
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: Post your modding questions here

by Ferk » Fri Oct 30, 2015 12:37

afeys wrote:I'm dumping mts files, and going to write a .we drawing function. I'll have a look at WorldEdit and see how they do it.

You could add serialize.lua and common.lua from here: https://github.com/Uberi/Minetest-World ... /worldedit
Maybe merge the two files into one and replace s/worldedit/afeysmod/g
Then use the worldedit.serialize and worldedit.deserialize functions (or you can remove the whole serialize part and only use deserialize). They work with strings, you just need to write/read them to files.

Note also that worldedit is AGPL, only use their code if your license is compatible.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Fri Oct 30, 2015 20:36

afeys, in 'place schematic' you should get the modpath like this (here the mod is called 'projects' and 'schematics' is the schematic folder) hope this works:

local path = minetest.get_modpath("projects") .. "/schematics/flat.mts"
minetest.place_schematic({x=x-6, y=y-1, z=z+1}, path, 90, nil, true)
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Mon Nov 02, 2015 14:34

paramat wrote:afeys, in 'place schematic' you should get the modpath like this (here the mod is called 'projects' and 'schematics' is the schematic folder) hope this works:

local path = minetest.get_modpath("projects") .. "/schematics/flat.mts"
minetest.place_schematic({x=x-6, y=y-1, z=z+1}, path, 90, nil, true)


Hi Paramat,

thanks for your answer. That was the way I was doing it in my mod. I just hardcoded the path in my cut-down code to make my testcase as simple as possible in an effort to find out what was going wrong.
I have now removed the place_schematic completely and code my own version in lua which reads the .we file data and does a minetest.add_node for each block. And again, sometimes the structure gets placed and other times it doesn't get placed. It is slowly driving me crazy.

Is it possible that my minetest.register_on_generated gets called before any biome (or other mod) register_on_generated function gets called and that whatever I put in the world gets overwritten/undone by another mod?
I have noticed that structures which get generated above water (sea) are shown (I have removed any checks to see if the structure is on solid ground), but structures which get generated in a jungle biome (for example) are not visible.

Also: for a test, I replace the groundlevel node at the x/z coordinates where my building is supposed to be generated with a mossy cobblestone block. And that block is always present. Anything which generates above ground is missing.

Is there a way to make sure that my mod's register_on_generated gets called after any biome generation ?
 

afeys
Member
 
Posts: 17
Joined: Thu Mar 26, 2015 08:55

Re: Post your modding questions here

by afeys » Tue Nov 03, 2015 12:33

just to let you know: I've solved it by placing my buildings using voxelmanip instead of place_schematics or add_node.

Buildings get generated now 100% of the time (at least during my test)
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Tue Nov 03, 2015 21:21

The problem might be because 'place schematic' is not meant to be used during mapgen, because it has it's own lighting update, what we need is a feature to add a schematic to the luavoxelmanipulator, much like the way you're doing it from a .we file. Because there is no unnecessary duplicated lighting update your method may even be faster than 'place schematic'.

'On generated' is always run after core biome generation.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Wed Nov 04, 2015 18:31

afeys and others, the new feature will soon be added https://github.com/minetest/minetest/pull/3339
"This commit adds a new API function minetest.place_schematic_on_vmanip()"
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron