Post your modding questions here

Joz
Member
 
Posts: 40
Joined: Fri Oct 25, 2013 21:37

Re: Post your modding questions here

by Joz » Sun Aug 16, 2015 20:36

What is the best method to determine if the actual node has been initialised?

Themes: world generating, singlenode

When my lua map generators write nodes into an uninitialised chunk (for example trees, special caves, big pyramids…) the changes will be overridden when the on_register function of that chunk is called. There will be cut trees and leaf hanging in the air decaying.

So I have to know which nodes have been placed by a map generator. Is this possible? I tried it with testing if a node's id is not == minetest.get_content_id("ignore") but no node had this id. I also tried the same with …content_id("air") but there were still many empty chunks.

Thanks in advance!
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Fri Aug 21, 2015 01:19

Does anyone know of a fast way to hash 2 or more numbers together in Lua such that the result is deterministic, depends on the order of the parameters, and has a reasonably low probability of collisions?
Almost any standard hash function would be fine, but Lua 5.1 doesn't even support bitwise operators which rather limits my options.

The reason I need this is that I want to generate deterministic seeds from xyz coordinates and edges in a graph. It was incredibly easy to throw together a proof-of-concept cave generator in Python, but now that I'm trying to port it to Lua I'm fighting against awkward syntax and missing features.

The best idea I have had so far is to use minetest's PRNG with a function like:
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 hash(n1,n2)
  local prng = PseudoRandom(n1)
  local n3 = prng.next() + n2
  prng = PseudoRandom(n3)
  return prng.next()
end

but creating a new PRNG object for every number I want to hash just seems horribly inefficient.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

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 » Fri Aug 21, 2015 07:41

Isn't Minetest. Serialise position for this purpose?
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Fri Aug 21, 2015 08:25

rubenwardy wrote:Isn't Minetest. Serialise position for this purpose?

Is it? Can PseudoRandom(seed) accept a string as its seed, and will it use the entire string rather than just truncating it? If so, that would simplify things massively.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

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 » Fri Aug 21, 2015 08:52

wrong name, it's minetest.hash_node_position({x=,y=,z=})

http://rubenwardy.com/minetest_modding_ ... .html#misc
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Fri Aug 21, 2015 10:44

How can l make a function which can change a inventory image of an item by adding the image onto the old one modifying the formspec?
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Fri Aug 21, 2015 16:50

rubenwardy wrote:wrong name, it's minetest.hash_node_position({x=,y=,z=})

http://rubenwardy.com/minetest_modding_ ... .html#misc


That's perfect, thanks. I'll remember to use that site (or lua_api.txt) in future instead of relying on the wiki.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

User avatar
Sane
Member
 
Posts: 103
Joined: Tue Jun 17, 2014 09:31
GitHub: mt-sane
In-game: Sane

minetest.find_path() algorithms

by Sane » Sat Aug 22, 2015 13:10

Hi there,

the minetest.find_path() function has an parameter to set the searching algorithm ("A*_noprefetch", "A*", "Dijkstra"),
I am wondeing what the differences are. Is there a documentation on them somewhere?
Trying to stay me.
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: minetest.find_path() algorithms

by ArguablySane » Sat Aug 22, 2015 14:16

Sane wrote:Hi there,

the minetest.find_path() function has an parameter to set the searching algorithm ("A*_noprefetch", "A*", "Dijkstra"),
I am wondeing what the differences are. Is there a documentation on them somewhere?

Wikipedia has articles on both Dijkstra's Algorithm and the A* Algorithm. In simple terms, the A* algorithm is usually a lot faster and more efficient than Dijkstra's algorithm, especially in cases where there are a large number of possible paths you could take to get from A to B (eg. A and B are on opposite sides of a large field). Dijkstra's might be faster in certain designs of maze though.
I'm not sure what A*_noprefetch is though.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

Joz
Member
 
Posts: 40
Joined: Fri Oct 25, 2013 21:37

Re: Post your modding questions here

by Joz » Mon Aug 24, 2015 13:22

With what NodeID are nodes initialised in singlenode?
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Mon Aug 24, 2015 14:15

Joz wrote:With what NodeID are nodes initialised in singlenode?

By default, it's air (minetest.get_content_id("air")). I believe there's a way to customise it from within a mapgen mod though.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

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 » Tue Aug 25, 2015 01:38

I have a number of tables set up.
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 chis1 = stuff
local chis2 = stuff
local hori1 = stuff
local hori2 = stuff
local vert1 = stuff
local vert2 = stuff
etc

Then I have another table set up.
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 modes = {
   {"chiseled", "Chiseled", chis},
   {"horizontal", "Horizontal", hori},
   {"vertical", "Vertical", vert},
   {"cross", "Cross", cross},
   }
for i in ipairs (modes) do
local mode = modes [i][1]
local mdesc = modes [i][2]
local typ = modes [i][3]

How do I join them? I want to make it so that it puts the type then a number so it is read as vert1 or hori1.
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
node_box = typ.."1",
node_box = typ.."2"
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
 

JasonGrace246
New member
 
Posts: 2
Joined: Tue Aug 25, 2015 05:04
GitHub: jasongrace246
In-game: JasonGrace246

Re: Post your modding questions here

by JasonGrace246 » Tue Aug 25, 2015 05:27

I am using the Cart Mod of PilzAdams (https://forum.minetest.net/viewtopic.php?id=2451) and its not working.
First it gave the characters not allowed error, so I changed the folder's name to "carts".
But now it gives me this error-

error.JPG

Brief Description Of Error-
The init.lua file in the mod throws an error saying- "Attempt to concatenate a nil value"
then its says "in main chunk" "check debug.txt for details"

PLEASE HELP
How To Get This Mod Working?
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Tue Aug 25, 2015 12:36

Don, am I right in thinking that you want to assign the value of chis1/hori1/etc (in this case "stuff"), to node_box?
You're going to have to iterate over a table of references to each type, but it would be helpful to know exactly what you're going to be using this code for. If I know the context I might be able to suggest a much simpler way of doing it.

JasonGrace, please post the full error message. It should say which line of init.lua the error is occurring on.


Oh, and I have a question of my own. If I'm writing a mapgen, is there a way to make sure the mapgen runs before any other mods? I know depends.txt lets me specify other mods which have to run before mine, but I'd like to make sure that my mod has a chance to actually create the terrain before other mods add things to it.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

User avatar
swordpaint12
Member
 
Posts: 187
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]

Re: Post your modding questions here

by swordpaint12 » Tue Aug 25, 2015 12:52

Nevermind, I was right.
Last edited by swordpaint12 on Tue Aug 25, 2015 13:11, edited 1 time in total.
Winter Cumicles
God's not dead; remember that!
Yay for MT! No MC here!
I am a human. I'm younger than 100 years old.
I've been playing Minetest since December 2014.
Fruit!

I'm amazed that I haven't been on here in so long! My latest minetest accomplishment was mining by hand (well, as close as you can get in a computer game) a circle 30 blocks in diameter. It took forever but it's pretty cool.
 

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 » Tue Aug 25, 2015 13:09

swordpaint12 wrote:I remember reading somewhere that a special file was required to make something a modpack. I think was modpack.txt, but I'm not sure. What is the title supposed to be?

I am trying to bundle a couple of the mods I have downloaded together so they are easier to enable. It's just for some worlds I'm working on.

Just put an empty file called modpack.txt
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
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Post your modding questions here

by Sokomine » Tue Aug 25, 2015 17:57

ArguablySane wrote:Oh, and I have a question of my own. If I'm writing a mapgen, is there a way to make sure the mapgen runs before any other mods? I know depends.txt lets me specify other mods which have to run before mine, but I'd like to make sure that my mod has a chance to actually create the terrain before other mods add things to it.

There's no such option. At least I don't know of any other than the depends.txt approach.
A list of my mods can be found here.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Wed Aug 26, 2015 10:31

Sokomine wrote:
ArguablySane wrote:Oh, and I have a question of my own. If I'm writing a mapgen, is there a way to make sure the mapgen runs before any other mods? I know depends.txt lets me specify other mods which have to run before mine, but I'd like to make sure that my mod has a chance to actually create the terrain before other mods add things to it.

There's no such option. At least I don't know of any other than the depends.txt approach.

you could try table.insert(minetest.registered_on_generateds, 1, function(minp,maxp,seed)
[…]
end)

l guess ores and mgv6 would still be generated before that.

Edit: l just used it myself: https://github.com/HybridDog/fractured/ ... 53e79d30c6
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Wed Aug 26, 2015 17:21

Hybrid Dog wrote:you could try table.insert(minetest.registered_on_generateds, 1, function(minp,maxp,seed)
[…]
end)

Oohhh, that's clever. Thanks for the idea.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

User avatar
swordpaint12
Member
 
Posts: 187
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]

Re: Post your modding questions here

by swordpaint12 » Sun Aug 30, 2015 18:19

Is there any way to create a block that is basically a vertical slab? If so, how do I do that?
Winter Cumicles
God's not dead; remember that!
Yay for MT! No MC here!
I am a human. I'm younger than 100 years old.
I've been playing Minetest since December 2014.
Fruit!

I'm amazed that I haven't been on here in so long! My latest minetest accomplishment was mining by hand (well, as close as you can get in a computer game) a circle 30 blocks in diameter. It took forever but it's pretty cool.
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: Post your modding questions here

by ArguablySane » Sun Aug 30, 2015 20:10

swordpaint12 wrote:Is there any way to create a block that is basically a vertical slab? If so, how do I do that?

You can set the drawtype to nodebox to create blocks which don't fill the entire volume.
You'll need to set paramtype2 == "facedir" in your nodedef to be able to make it rotate to any of the 4 (or 6) possible alignments.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Aug 31, 2015 08:39

swordpaint12 wrote:Is there any way to create a block that is basically a vertical slab? If so, how do I do that?

you could use the screwdriver
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Mon Aug 31, 2015 09:28

Slabs *can* be placed on the side of a node so that it stands UP...
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Aug 31, 2015 09:45

TenPlus1 wrote:Slabs *can* be placed on the side of a node so that it stands UP...

When l place a slab on the side of a node it doesn't stand up.
If they did, building roofs with slabs would become far more annoying.
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Mon Aug 31, 2015 10:30

Apologies, I use a different version of Stairs mod that allows for on_rotate functions so that you can place slabs on floor or wall and have a different rotation with both (or hold shift and place on wall to place flat/normal)...

I've attached it here if you wish to use it:
Attachments
stairs(redo).zip
(1.29 KiB) Downloaded 45 times
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Aug 31, 2015 10:36

TenPlus1 wrote:Apologies, I use a different version of Stairs mod that allows for on_rotate functions so that you can place slabs on floor or wall and have a different rotation with both (or hold shift and place on wall to place flat/normal)...

I've attached it here if you wish to use it:

no, thanks, l try to build bigger, e.g. to get more details, instead of e.g. using slabs to build thin walls
 

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 » Mon Aug 31, 2015 12:22

Slabs made from the saw in moreblocks rotate on place.
viewtopic.php?id=509
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
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Aug 31, 2015 13:00

Don wrote:Slabs made from the saw in moreblocks rotate on place.
viewtopic.php?id=509

l know, that's extremely annoying in my opinion.
 

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 » Mon Aug 31, 2015 14:15

Hybrid Dog wrote:
Don wrote:Slabs made from the saw in moreblocks rotate on place.
viewtopic.php?id=509

l know, that's extremely annoying in my opinion.

I love it. No need for the screwdriver.
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
swordpaint12
Member
 
Posts: 187
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]

Re: Post your modding questions here

by swordpaint12 » Mon Aug 31, 2015 16:44

Hybrid Dog wrote: If they did, building roofs with slabs would become far more annoying.


Actually, that's WHY I asked. I'm trying to make a tall roof using 'walls.'
Winter Cumicles
God's not dead; remember that!
Yay for MT! No MC here!
I am a human. I'm younger than 100 years old.
I've been playing Minetest since December 2014.
Fruit!

I'm amazed that I haven't been on here in so long! My latest minetest accomplishment was mining by hand (well, as close as you can get in a computer game) a circle 30 blocks in diameter. It took forever but it's pretty cool.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 60 guests

cron