Page 125 of 125

Re: Post your modding questions here

PostPosted: Sat Mar 25, 2017 09:17
by mbb
thx for your help now i need other one
how i can generate a 1 block deep ozean per mod?

Re: Post your modding questions here

PostPosted: Sat Mar 25, 2017 12:33
by Hybrid Dog
Philosoph228 wrote:How can I get the maximum and minimum heights of the world?

http://wiki.minetest.net/End_of_the_wor ... _the_world

mbb wrote:how i can generate a 1 block deep ozean per mod?

You can use vmanip http://dev.minetest.net/vmanip#Examples

Re: Post your modding questions here

PostPosted: Sun Mar 26, 2017 03:15
by RealGoldenHart
Three questions, I think they are all impossible, but that's what this forum is for...pro coders solving my noobish problems.

1. How would I go about setting a node to be collidable with all but one other node? To be more specfic, I want node a to be able to go through node b, but I don't want node c, or any other node, to be able to go through node b. I also want to be able to build on node b.... soo I'm confused.

2. Can I make a node able to travel up after taking a certain action, such as right clicking the node.

3. How would I go about generating a realm in the sky? For example, rather than in caverealms where the realms are spawned underground, is it possible to do that in the sky?
Now...I realize this makes the mod impossible for servers to add, because they would have to make a new world for this addition. Is there any alternative that achieves the same goal?

I am new to Lua coding, and Mt modding in general. I do have a bit of c++ experience. Not as much as most though. Thanks for reading and I hope you have some answers for me.

If this mod idea doesn't work, I will happily move on over to something else, maybe I shouldn't try something so big for my first mod, but I think I have an idea of how to develop this.

Re: Post your modding questions here

PostPosted: Sun Mar 26, 2017 05:28
by sofar
RealGoldenHart wrote:1. How would I go about setting a node to be collidable with all but one other node? To be more specfic, I want node a to be able to go through node b, but I don't want node c, or any other node, to be able to go through node b. I also want to be able to build on node b.... soo I'm confused.


Nodes can't move. Period.

Nodes can temporarily fall, but they'll stop as soon as they hit another (non-air) node.

Re: Post your modding questions here

PostPosted: Sun Mar 26, 2017 05:29
by sofar
RealGoldenHart wrote:2. Can I make a node able to travel up after taking a certain action, such as right clicking the node.


Nodes can't move. Period.

You can fake movement by removing the node at position A, and then making a new node that looks just like it at position B. It will look like it moved, but it didn't.

API relevant functions:

minetest.remove_node(pos)
minetest.set_node(pos, node)

Re: Post your modding questions here

PostPosted: Sun Mar 26, 2017 06:45
by dawgdoc
You may find some usable code in the Pontoons mod. I recall it is used to make under water builds float to the surface and become floating buildings. But, I think that mod converted the building to an entity, floated the entity up, and then converted it back to nodes. It is entirely possible that it will not be of any use to you. There was a distinct stopping point for the events to occur; that is when the entity had air above in instead of water. I don't know how you can change the code to suit your purposes.

Re: Post your modding questions here

PostPosted: Sun Mar 26, 2017 11:37
by RealGoldenHart
Alright thanks guys. I will try a different mod. Thanks for teaching me. I thought if you could move a vehicle around in a vehicles mod, that maybe you could move an air transport or something up. Ttyl

Re: Post your modding questions here

PostPosted: Mon Mar 27, 2017 21:50
by orwell
RealGoldenHart wrote:3. How would I go about generating a realm in the sky? For example, rather than in caverealms where the realms are spawned underground, is it possible to do that in the sky?
Now...I realize this makes the mod impossible for servers to add, because they would have to make a new world for this addition. Is there any alternative that achieves the same goal?

I, personally, have no idea of mapgen stuff of any kind.
- Mapgen v7 has floatlands. they are disabled but can be enabled
- Terrain gets generated in 3d cubes of 80 nodes in diameter, not in 2d chunks like in Minecraft. So, if no one ever flew up to the heights you want the sky realm to be generated, an existing world is no problem, because the sky terrain has not yet been generated.

Re: Post your modding questions here

PostPosted: Thu Mar 30, 2017 15:46
by cx384
What is the best way to put the names of all files (folders) which are in one folder into a table?
(I want to get a table which contains the name of all existing texture packs (path = /.minetest/textures ))

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:19
by burli
How can I debug lua code? I need to run a code step by step to check variables, but I don't know how. I tried to use player controls (key input), but that doesn't work, however

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 function stepkey()
   local player = minetest.get_player_by_name("singleplayer")
   repeat
   until player:get_player_control().aux1
   repeat
   until not player:get_player_control().aux1
end

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:28
by cx384
You can write print("variable") in every line.

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:29
by orwell
Can't you use print() instructions to print values after each step?
Minetest is not multithreaded, whenever a event function blocks (such as running an infinite loop) the server can't do anything else, it can't even update the player control status. So you may not wait inside callback functions using loops.
You might achieve something like you want using coroutines, but these are broken inside the callbacks for some reason

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:30
by burli
cx384 wrote:You can write print("variable") in every line.

That's too fast and too much. I need to stop the code to analyse the data

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:37
by orwell
maybe print just everything...
print(dump(table_of_all_relevant_data))
There is no other way

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 07:43
by burli
orwell wrote:maybe print just everything...
print(dump(table_of_all_relevant_data))
There is no other way

As I said, too fast and too much for console output. I write to a file now

Re: Post your modding questions here

PostPosted: Sat Apr 01, 2017 21:23
by orwell
Maybe (but only maybe) this is useful for you. It's a simple ring buffer. I used it to debug a problem in my advtrains mod, because I couldn't reproduce the bug but only detect when it was happening, so I needed to let some trains run and let them trigger the dump when some component recognized that something was wrong
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 ringbuflen=200

local ringbufs={}
local ringbufcnt={}

function advtrains.drb_record(tid, msg)
   if not ringbufs[tid] then
      ringbufs[tid]={}
      ringbufcnt[tid]=0
   end
   ringbufs[tid][ringbufcnt[tid]]=msg
   ringbufcnt[tid]=ringbufcnt[tid]+1
   if ringbufcnt[tid] > ringbuflen then
      ringbufcnt[tid]=0
   end
end
function advtrains.drb_dump_and_exit(pts, tid)
   print("Train "..tid.." dumping ringbuffer at pos:", pts)
   local stopcnt=ringbufcnt[tid]
   repeat
      minetest.log("action", ringbufcnt[tid]..ringbufs[tid][ringbufcnt[tid]])
      ringbufcnt[tid]=ringbufcnt[tid]+1
      if ringbufcnt[tid] > ringbuflen then
         ringbufcnt[tid]=0
      end
   until ringbufcnt[tid]==stopcnt
   minetest.log("action", dump(advtrains.trains[tid]))
   error("Successfully dumped stuff")
end