Post your modding questions here

Locked
User avatar
everamzah
Member
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Post

I generally use Programming in Lua[1] which covers 5.0. Is string.trim() a 5.1 feature? Is there a good place to learn more about how to use it? Related: Is filtering for only A-Z and a-z and 0-9 better than trying to filter out anything like spaces, apostrophes, etc.?
[1] http://www.lua.org/pil

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Post your modding questions here

by kaeza » Post

string.trim is Minetest-specific, documented in doc/lua_api.txt, and implemented in builtin/common/misc_helpers.lua, IIRC
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
jp
Banned
Posts: 947
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith
Location: France

Re: Post your modding questions here

by jp » Post

Or that :

Code: Select all

param:gsub("%W", "")
(note : %W in uppercase, different from %w)

User avatar
everamzah
Member
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Post

jp wrote:Or that :

Code: Select all

param:gsub("%W", "")
(note : %W in uppercase, different from %w)
that seems to do the trick! thanks very much for help HybridDog, kaeza, and jp. :)

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

Re: Post your modding questions here

by Ferk » Post

minetest.luaentities only holds the entities that are currently loaded.

Is there a way I can obtain all the entities of an area? ...or force an area to be loaded, along with its entities.

Alternatively: given a particular area, how can I know if all the entities inside it are loaded? this way at least I could tell apart the entities that were removed from the ones that are simply not loaded and update my data accordingly.

I could assume that the area around an entity has been completely loaded every time I find an entity. But then if a player removed all the entities from an area I won't have a way to know if it was simply not loaded.

Thanks!
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }

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

Re: Post your modding questions here

by ArguablySane » Post

Ferk wrote:minetest.luaentities only holds the entities that are currently loaded.

Is there a way I can obtain all the entities of an area? ...or force an area to be loaded, along with its entities.

Alternatively: given a particular area, how can I know if all the entities inside it are loaded? this way at least I could tell apart the entities that were removed from the ones that are simply not loaded and update my data accordingly.

I could assume that the area around an entity has been completely loaded every time I find an entity. But then if a player removed all the entities from an area I won't have a way to know if it was simply not loaded.

Thanks!
There are functions to force-load an area. I'm not sure of their range though:
minetest.forceload_block(pos)
minetest.forceload_free_block(pos)

You can check if an area is loaded by querying a node inside it and seeing if you get "ignore",
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.

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

Re: Post your modding questions here

by Ferk » Post

Thanks for the reply, ArguablySane :)
ArguablySane wrote:There are functions to force-load an area. I'm not sure of their range though:
minetest.forceload_block(pos)
minetest.forceload_free_block(pos)
I didn't know about this, thanks.
However, it seems that this only loads the node in the position given and it won't load the entities around this node
You can check if an area is loaded by querying a node inside it and seeing if you get "ignore",
This would have been already good enough for my case.. but it seems entities have a much lower range than nodes. I still discover entities that get unloaded when the player walks away even though the block where they were placed is still loaded.

What is the range from the player in which the entities get loaded/unloaded? Maybe at least I can get the entities close to the player to update properly.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }

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

Re: Post your modding questions here

by Don » Post

I think that is the active_block_range in minetest.conf
https://github.com/minetest/minetest/bl ... nf.example
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
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Post your modding questions here

by Nathan.S » Post

I'm trying to determine what node is placed in an inventory slot. Currently I know how to check if the inventory is a certain item with if inv:contains_item('slot_name', 'item_name') then
however I'm trying to create a local value that has that item_name as it's value, so I can drop that item to the ground on a button click, or move it to the player inventory with a button.
I'm guessing this should be possible, I just can't seem to figure it out.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

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

Re: Post your modding questions here

by Ben » Post

Nathan.S wrote:I'm trying to determine what node is placed in an inventory slot. Currently I know how to check if the inventory is a certain item with if inv:contains_item('slot_name', 'item_name') then
however I'm trying to create a local value that has that item_name as it's value, so I can drop that item to the ground on a button click, or move it to the player inventory with a button.
I'm guessing this should be possible, I just can't seem to figure it out.
The dev wiki on InvRefs should contain everything you need. But since you wrote "if the inventory is a certain item", and refer to the first parameter as "slot_name", I'm not sure you understand that each of these "slots" is in fact a list of slots. If you do, my apologies; other readers may not, so it can't hurt to mention it.

The following code should iterate over an inventory list:

Code: Select all

for i=1, inv:get_size('slot_name') do
  local stack = inv:get_stack('slot_name', i)
  local name = stack:get_name()
  --# do stuff with name and stack
  inv:set_stack('slot_name', i, new_stack) --# write back changes
end
Does that help?

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

Re: Post your modding questions here

by Ben » Post

ArguablySane wrote:There are functions to force-load an area. I'm not sure of their range though:
minetest.forceload_block(pos)
minetest.forceload_free_block(pos)
A related question: I'm contemplating a teleportation mod with a delay of a second or two. After this time, I will most likely teleport a player to a given position, the server might as well have this position loaded by that time. I'd also like to query the nodes at the position being teleported to, but this is not strictly required.

Now I could forceload the position in question at the start of the two seconds, and free it after teleportation, but that seems very heavy-handed. Also, what if the position was already forceloaded by other means? With no way to check, I would clobber that.

Is there an alternative way to "hint" to the server that the area will become relevant? An actual method call as above, or a trick like spawning a temporary entity there?

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Post your modding questions here

by Nathan.S » Post

Ben, you are my HERO, okay that might be going overboard, but yes, that code you provided is exactly what I needed.
I hadn't realized that each of those slots are a list of slots, but I guess that makes sense as you can have them be more than one slot. Coincidentally this could also be what I need to finish my smoker, as it has multiple slots for input, and all of them with meat need to be replaced once the smoking is done. A million thank yous.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Ben wrote:
ArguablySane wrote:There are functions to force-load an area. I'm not sure of their range though:
minetest.forceload_block(pos)
minetest.forceload_free_block(pos)
A related question: I'm contemplating a teleportation mod with a delay of a second or two. After this time, I will most likely teleport a player to a given position, the server might as well have this position loaded by that time. I'd also like to query the nodes at the position being teleported to, but this is not strictly required.

Now I could forceload the position in question at the start of the two seconds, and free it after teleportation, but that seems very heavy-handed. Also, what if the position was already forceloaded by other means? With no way to check, I would clobber that.

Is there an alternative way to "hint" to the server that the area will become relevant? An actual method call as above, or a trick like spawning a temporary entity there?
l think voxel manipulation works in unloaded chunks

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

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

Re: Post your modding questions here

by Ferk » Post

Hybrid Dog wrote:l think voxel manipulation works in unloaded chunks
I'm wondering how does this work for chunks that were not only unloaded but also not generated.
I mean, would the engine automatically generate the area as soon as you try to perform any manipulation in there?

If for example, I define an on_generate callback for a particular area that loads a big mts schematic that covers several chunks, will all the chunks that would be affected by my mapgen have to be generated?

This means that if I add too many areas that load mts schematics it could cause a chain of on_generate calls that could potentially lock up the server. Is that correct?

If that's the case I guess it would be faster for my mapgen to try to parse the mts files from lua and feed it every time to the mapgen algorithm within the limits of the on_generate call.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }

User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Ferk wrote:
Hybrid Dog wrote:l think voxel manipulation works in unloaded chunks
I'm wondering how does this work for chunks that were not only unloaded but also not generated.
I mean, would the engine automatically generate the area as soon as you try to perform any manipulation in there?
No, but if the map gets generated there, core mapgen (should) only replaces nodes which are ignore and keeps the other ones (firstly). l thought you mean a teleporter like the one of Zeg9, so generated but unloaded (because of rejoining) chunks.
If for example, I define an on_generate callback for a particular area that loads a big mts schematic that covers several chunks, will all the chunks that would be affected by my mapgen have to be generated?
No, but if the map becomes generated there, stone walls get ores, caves appear, etc.
This means that if I add too many areas that load mts schematics it could cause a chain of on_generate calls that could potentially lock up the server. Is that correct?
no, putting nodes into not generated chunks doesn't call the mapgen functions there
If that's the case I guess it would be faster for my mapgen to try to parse the mts files from lua and feed it every time to the mapgen algorithm within the limits of the on_generate call.
lf you place schematics in not generated areas, stone walls may get ores, caves may appear, etc.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
swordpaint12
Member
Posts: 191
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]
Location: Foobass, isle of Atlantis, castle of Bardvendelle

Re: Post your modding questions here

by swordpaint12 » Post

Okay, so I am working on a practice mod suggested in rubenwardy's book, and I need to know where to find the contents of the default mod so I can use it. Do any of you know where that may be?
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.

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
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Post your modding questions here

by Nathan.S » Post

swordpaint12 wrote:Okay, so I am working on a practice mod suggested in rubenwardy's book, and I need to know where to find the contents of the default mod so I can use it. Do any of you know where that may be?
If you running Linux and installed from a PPA or software center they will be in usr/share/minetest/ if you compile yourself, guessing not though, they'll be in your directory you compiled in. Not sure on Windows, but this article on the wiki should help. http://wiki.minetest.net/Installing_Mods
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
swordpaint12
Member
Posts: 191
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]
Location: Foobass, isle of Atlantis, castle of Bardvendelle

Re: Post your modding questions here

by swordpaint12 » Post

I'm on Windows. I managed to find an edited version in one of my sub games. I just got past that. Now, I'm puzzling over

Code: Select all

action = function(pos, node, active_object_count, active_object_count_wider)
		minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "aliens:grass"})
It isn't really making any sense to me. It's in chapter six.
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.

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
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Post your modding questions here

by Nathan.S » Post

swordpaint12 wrote:I'm on Windows. I managed to find an edited version in one of my sub games. I just got past that. Now, I'm puzzling over

Code: Select all

action = function(pos, node, active_object_count, active_object_count_wider)
		minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "aliens:grass"})
It isn't really making any sense to me. It's in chapter six.
Well this is an action that is called when you do something, not sure what comes before the action part, I'm guessing on_dig, on_place, on_punch, on_rightclick, anyway. When this action is called Minetest sets a node, in this case aliens:grass, which will probably come up as an unknown node, unless you have an aliens mod installed. I might replace that will default:dirt or something. The location of the node is in the table {x = pos.x, y = pos.y + 1, z = pos.z} the pos, or position is passed on to the action, pos contains X, Y, and Z data, the table just adds one to the y position. When the action is called the node will be placed one node above the current node.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
swordpaint12
Member
Posts: 191
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]
Location: Foobass, isle of Atlantis, castle of Bardvendelle

Re: Post your modding questions here

by swordpaint12 » Post

So, do I need to do anything with it? I'm practicing on the decay mod as suggested at the end of that chapter. Do I need to change anything with it, like enter in numbers? Sorry, I'm pretty new at this. Do I just copy it in to my code?
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.

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
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Post your modding questions here

by Nathan.S » Post

It should be good as is, but you could play around with the numbers just to see the difference.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Post your modding questions here

by paramat » Post

Ben wrote:A related question: I'm contemplating a teleportation mod with a delay of a second or two. After this time, I will most likely teleport a player to a given position, the server might as well have this position loaded by that time. I'd also like to query the nodes at the position being teleported to, but this is not strictly required.
As far as i know, for teleportation to an ungenerated area, you need to know what the ground level will be at that point before mapgen generates it. Then teleport the player to that point and altitude to trigger mapgen, the player will float trapped in 'ignore' nodes until the terrain is generated.
So far this can only be done by porting mgv6 mapgen into a lua mod to predict the ground level at a certain point. Possible but not easy. There are core functions that get ground level at point for each mapgen but i would have to add APIs for those, i might actually do this.

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

Re: Post your modding questions here

by Ferk » Post

Hybrid Dog wrote:l thought you mean a teleporter like the one of Zeg9
paramat wrote:for teleportation to an ungenerated area [...]
Ow.. my question regarding manipulations on non-generated chunks was not really about the teleportation mod from Ben, I'm working on a different project. Though the question was related and your replies have been insightful, thank you.

I'm making a game that divides the map in rooms for an infinite dungeon maze, where each room is randomly chosen from a set of selected schematics. The idea is that people would be able to create their own "challenge rooms" and add them to the pool so the number of possibilities keeps growing.

So far I have the layout and I can generate an infinite binary-tree maze of rooms fairly fast. However, loading the (worldedit) schematics slows down the generation quite a lot. I was thinking on ways to optimize it.

Would using mts files instead of worldedit improve the performance?

How does the mapgen know how further away from the player it needs to generate? My game will be full of closed walls, so I don't really need a big radius. So far I was trying to ease the amount of rooms generated simultaneously by putting bigger gaps between the levels. But there's still a lot of generation going on.

Maybe I should decouple the schematic load from the mapgen. Something like.. have an ABM in the center of each room that loads the schematic as soon as it's at a distance from the player. This way I can control better the pace in which the schematics load. Would this be a good idea?

Also, right now I'm using singlenode. But it might be cool to consider using some mapgen in such a way that the whole underground can be the dungeon while the surface can have the standard biomes, if I figure out a way to make the mapgen not interfere with the dungeon (I guess I can disable ores, but I'm not so sure about lava, caverealms seemed to have trouble with that, maybe being a subgame helps here).
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }

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

Re: Post your modding questions here

by Don » Post

@Ferk - I did something similar with mineshafts. It is a work in progress. I found that .mts files seem to load better then we files for larger schematics.
I made a node that is used as a point to place the schematic. Then i generated it with register_ore. Then I used an abm to place the schematic.
The shafts.lua has the code I am talking about if you want to see. Please let me know if you find a better way.
https://github.com/DonBatman/mymineshaft
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

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

Re: Post your modding questions here

by DoyleChris » Post

Im wondering if there is a way that a pipe supplying a technic grinder to know if the queue in the grinder is full or different item.

Example I have a grinder being feed by a pipe, grinder already is working on iron, i want to feed iron to it till its done. Then work on another kind and not have it send copper down the pipe when its working on iron.
I have tried it and the copper just stays in the tube.

Locked

Who is online

Users browsing this forum: No registered users and 5 guests