Post your modding questions here

User avatar
cx384
Member
 
Posts: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Jul 09, 2017 06:26

texmex wrote:Is there an existing API mod I can use to place small buildings around the map?

Maybe this would help you.
viewtopic.php?t=6221

Lone_Wolf wrote:Question1:
Where is the setting to make my map smaller and does the map side have to be divisible by 16*16*16?

It is called mapgen_limit.
https://github.com/minetest/minetest/bl ... mple#L1194
mapgen_limit haven't to be divisible by 16, but "only mapchunks completely within the mapgen limit are generated".
(one mapchunks ≙ 16*16*16 nodes)
Lone_Wolf wrote:Question2:
If I wanted to make a map is it ok to post all the map's mods as a subgame?

You should put the mods into the worldmods folder.
http://wiki.minetest.net/Maps#.2Fworldmods_.28folder.29
Can your read this?
 

ABJ
Member
 
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sun Jul 09, 2017 10:04

Where is located the definition of functions such as minetest.register_node? I'm trying to create a new function for physics sandbox.
 

User avatar
texmex
Member
 
Posts: 1536
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: Post your modding questions here

by texmex » Sun Jul 09, 2017 10:47

cx384 wrote:
texmex wrote:Is there an existing API mod I can use to place small buildings around the map?

Maybe this would help you.
viewtopic.php?t=6221

Not quite, I want something to generate predefined structures, yes, but on map generation.
 

User avatar
cx384
Member
 
Posts: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Jul 09, 2017 11:43

texmex wrote:
cx384 wrote:
texmex wrote:Is there an existing API mod I can use to place small buildings around the map?

Maybe this would help you.
viewtopic.php?t=6221

Not quite, I want something to generate predefined structures, yes, but on map generation.

Caverealms does this with the fortress.
https://github.com/HeroOfTheWinds/minet ... ress&type=

But registering a node and an abm isn't efficient for structures, especially for big and various buildings.
Therefore you should probably use "minetest.register_on_generated(func(minp, maxp, blockseed))".
Nevertheless you can easily register decorations and ores to generate these nodes.
Last edited by cx384 on Sun Jul 09, 2017 12:10, edited 4 times in total.
Can your read this?
 

User avatar
cx384
Member
 
Posts: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Jul 09, 2017 11:50

ABJ wrote:Where is located the definition of functions such as minetest.register_node? I'm trying to create a new function for physics sandbox.

There:
https://github.com/minetest/minetest/bl ... r.lua#L204

but you should look there if you want to know anything about the function:
https://github.com/minetest/minetest/bl ... .txt#L4162
Can your read this?
 

ABJ
Member
 
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
GitHub: ABJ-MV
In-game: ABJ
 

User avatar
Lejo
Member
 
Posts: 634
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo
 

ABJ
Member
 
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sun Jul 09, 2017 16:40

I'm trying to register multiple nodes from a list with one call. I've forgotten how to do that. How is this done?
 

User avatar
texmex
Member
 
Posts: 1536
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: Post your modding questions here

by texmex » Sun Jul 09, 2017 16:53

cx384 wrote:Caverealms does this with the fortress.
https://github.com/HeroOfTheWinds/minet ... ress&type=

But registering a node and an abm isn't efficient for structures, especially for big and various buildings.
Therefore you should probably use "minetest.register_on_generated(func(minp, maxp, blockseed))".
Nevertheless you can easily register decorations and ores to generate these nodes.

Thanks, I'll follow up on those leads. I tried looking into various ruins mods too, but I couldn't figure that out.
 

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

Re: Post your modding questions here

by Sokomine » Mon Jul 10, 2017 16:19

texmex wrote:Is there an existing API mod I can use to place small buildings around the map?

If they're really small you might get away with spawning them in the way other decorations (i.e. trees) are spawned. That's very easy to implement and very fast. You only need to register your buildings as new decorations.

If you want the buildings to be integrated into the landscape, take a look at my mg_villages mod. It does spawn individual buildings as well. Even there the range of terrain blending may be too small in some cases.
A list of my mods can be found here.
 

User avatar
texmex
Member
 
Posts: 1536
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: Post your modding questions here

by texmex » Mon Jul 10, 2017 17:01

Sokomine wrote:
texmex wrote:Is there an existing API mod I can use to place small buildings around the map?

If they're really small you might get away with spawning them in the way other decorations (i.e. trees) are spawned. That's very easy to implement and very fast. You only need to register your buildings as new decorations.

If you want the buildings to be integrated into the landscape, take a look at my mg_villages mod. It does spawn individual buildings as well. Even there the range of terrain blending may be too small in some cases.

Small structures (as in ≈7x7x7) is what I'm thinking, so your suggested strategy sounds like the way to go. Thank you.
 

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

Re: Post your modding questions here

by Sokomine » Mon Jul 10, 2017 18:23

texmex wrote:Small structures (as in ≈7x7x7) is what I'm thinking, so your suggested strategy sounds like the way to go. Thank you.

That might already be too big. Still - give it a try! Spawning it as mapgen decoration isn't too much work. Maybe it'll look good enough already and you're done :-) Far easier than actually adjusting the landscape as mg_villages does.
A list of my mods can be found here.
 

KzoneDD
Member
 
Posts: 64
Joined: Wed Sep 17, 2014 09:29

Re: Post your modding questions here

by KzoneDD » Mon Jul 10, 2017 21:22

Is there a reason no one seems to register new oddly shaped nodes by iterating over already registered nodes?

If no, how would one go about that? I delved into loads of documentation, but I think my severely limited programming expertise is showing...
 

sofar
Developer
 
Posts: 2059
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Mon Jul 10, 2017 21:39

KzoneDD wrote:Is there a reason no one seems to register new oddly shaped nodes by iterating over already registered nodes?

If no, how would one go about that? I delved into loads of documentation, but I think my severely limited programming expertise is showing...


nodes need to be registered when all the modules are `initialized`. At this time, the list of already known nodes is in fluctuation, and you can not rely on the list being complete, because the order in which modules are loaded is random.

The only thing you can do is to force ordering by adding `depends.txt` on specific mods, so that you can safely assume that some nodes are already loaded and thus present in the registration list.

However, this still is guaranteed to miss out on nodes from mods that load after the code that does scanning for specific nodes.

And so, there just is no good way of making this generic, since you don't want to insert hundreds of fake dependencies in to your mod, which has other problems and could make other problems worse.

Bottom line is that doing a scan over registered nodes at init time is just bad design and should be avoided.
 

User avatar
Linuxdirk
Member
 
Posts: 2114
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Mon Jul 10, 2017 22:05

KzoneDD wrote:Is there a reason no one seems to register new oddly shaped nodes by iterating over already registered nodes?

I do with my xFurniture mod. (Causing a heavily discussed “Low priority”, “Non-trivial” “Request / Suggestion” about the node ID limit *g*)

KzoneDD wrote:If no, how would one go about that?

You need to (opt-)depend on the mods you want to support and then iterate over the already registered nodes and write them into another table and then iterate over that table to register the new nodes.

You can’t iterate over minetest.registered_nodes while registering nodes during the iteration because it will add entries to that table and thus the iteration becomes wonky and will break at some point. (Source)

Code: Select all
local wanted_nodes = {}

for name,def in pairs(minetest.registered_nodes) do
    -- Maybe filter what nodes you do not want.
    -- For example get only nodes that are solid (drawtype = normal)
    if def.drawtype == 'normal' then
        wanted_nodes[name] = def
    end
end

for name,def in pairs(wanted_nodes) do
    -- Now you can do whatever you want with your wanted nodes.
    -- You have the name and you have the ID ... go figure yourself :)
done

sofar wrote:Bottom line is that doing a scan over registered nodes at init time is just bad design and should be avoided.

Problem: You can only register new nodes at init time.
 

sofar
Developer
 
Posts: 2059
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Mon Jul 10, 2017 22:32

Linuxdirk wrote:
Code: Select all
local wanted_nodes = {}

for name,def in pairs(minetest.registered_nodes) do
    -- Maybe filter what nodes you do not want.
    -- For example get only nodes that are solid (drawtype = normal)
    if def.drawtype == 'normal' then
        wanted_nodes[name] = def
    end
end

for name,def in pairs(wanted_nodes) do
    -- Now you can do whatever you want with your wanted nodes.
    -- You have the name and you have the ID ... go figure yourself :)
done


This is a good solution to avoid the table maintenance problem, and indeed safe for the table.

There's always pros and cons to this. Because load order is random, if you register new nodes based on this list you will likely end up with unknown nodes on your map once in a while, so I still do not recommend it:

- mod foo creates new nodes for all "normal" nodes found in the registration list. They are named ":mod:node_foo"
- mod foo depends on mod bar, but not mod baz
- game loads, mod foo sees "bar:node" and "baz:node" and registers ":bar:node_foo" and ":baz:node_foo"
- player places ":baz:node_foo" on the map
- game shuts down
- game loads, but now mod "foo" is initialized *before* mod "baz"
- mod foo sees "bar:node" and registers ":bar:node_foo"
- unknown node ":baz:node_foo" now exists on the map.

The only way around that is to explicitly always (optionally) depend on the other mods and/or hard code the actual list of nodes that you want to handle, and check if they are registered. That method avoids the "unknown node" problem on your map. Yes, it's annoying to have to hard code the list of nodes, I realize that as well.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Mon Jul 10, 2017 23:13

You could first iterate over existing registered nodes, and then replace minetest.register_node with a version that performs your own node registrations (after calling the old registration).
Every time a mod API is left undocumented, a koala dies.
 

KzoneDD
Member
 
Posts: 64
Joined: Wed Sep 17, 2014 09:29

Re: Post your modding questions here

by KzoneDD » Mon Jul 10, 2017 23:14

Yeah, I hadn't thought of that... Thanks all. But seems to me, adding a list of depends is a lot less work still than registering each node when you add a mod... Is mod loading truly random? I'd have guessed it wold go by some order...
 

KzoneDD
Member
 
Posts: 64
Joined: Wed Sep 17, 2014 09:29

Re: Post your modding questions here

by KzoneDD » Mon Jul 10, 2017 23:22

So, just thinking out loud here; iterating over registered nodes, but only use the ones from mods that you've listed in depends... now, how to get the list of depends...
 

ABJ
Member
 
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Wed Jul 12, 2017 10:14

How do I get the position of a node selected by an ABM?
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Wed Jul 12, 2017 18:04

ABJ wrote:How do I get the position of a node selected by an ABM?

It's passed as an argument to your action callback.
Every time a mod API is left undocumented, a koala dies.
 

KzoneDD
Member
 
Posts: 64
Joined: Wed Sep 17, 2014 09:29

Re: Post your modding questions here

by KzoneDD » Wed Jul 12, 2017 21:29

Hi all,

Trying to figure out how to keep a node's texture the same regardless of rotation. I'm working on something that has top, bottom and middle parts, so I'd like to use only one registered node for top and bottom, but keep the textures direction the same so they keep matching... any ideas?
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
In-game: ExeterDad

Re: Post your modding questions here

by ExeterDad » Wed Jul 12, 2017 22:01

KzoneDD Are the top and bottom to be the same texture and the middle areas to be something else? You can define all six sides in your node def, so six different textures if you desire.
 

KzoneDD
Member
 
Posts: 64
Joined: Wed Sep 17, 2014 09:29

Re: Post your modding questions here

by KzoneDD » Wed Jul 12, 2017 22:06

Hi ExeterDad,

Thanks. :)

No, I have pillars, with a bottom tapered end, a top tapered end and a straight middle end. Now, if you have, say, a wood texture, that's striped. I'd like the stripes to keep running in the direction of the pillar (top to bottom) and connect. If you look at the default wood texture for example, the dark lines will be one step out of alignment if you simply turn the 'bottom' tapered end upside-down.
 

User avatar
texmex
Member
 
Posts: 1536
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: Post your modding questions here

by texmex » Wed Jul 12, 2017 22:10

KzoneDD wrote:Hi all,

Trying to figure out how to keep a node's texture the same regardless of rotation. I'm working on something that has top, bottom and middle parts, so I'd like to use only one registered node for top and bottom, but keep the textures direction the same so they keep matching... any ideas?

Textures being independent of its node's rotation can't be done in the Minetest engine currently. See issue #5222
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 6 guests