Post your modding questions here

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

Re: Post your modding questions here

by ExeterDad » Post

I somehow missed the "regardless of rotation" part. Sorry to of jumped in there too quickly. :)

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

Re: Post your modding questions here

by KzoneDD » Post

texmex wrote:
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
Aw, too bad... will have to register a top and bottom end then... Thanks!

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

Re: Post your modding questions here

by ABJ » Post

How do I check for a specific property of a node at a known position?

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

Re: Post your modding questions here

by ABJ » Post

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
	end
})
It says that there is an unexpected symbol near the } on line 11.
What am I doing wrong?

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

Re: Post your modding questions here

by Linuxdirk » Post

KzoneDD wrote:Aw, too bad... will have to register a top and bottom end then... Thanks!
Yep because none of the devs actually cares this won't be fixed within reasonable time. Just register what you need. I had to do the same because the rotated textures just look ugly.

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

Re: Post your modding questions here

by ExeterDad » Post

ABJ wrote:

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
	end
})
It says that there is an unexpected symbol near the } on line 11.
What am I doing wrong?
How about adding one more "end" to close the "action" function? (not tested)

Code: Select all

minetest.register_abm({
	nodenames = {"default:wood"},      
	interval = 10.0, 
	chance = 1,    
	action = function(pos, node, active_object_count, active_object_count_wider)
		local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
		local nodedef = minetest.registered_nodes[node]
		if nodedef.walkable == true then
			minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
		end
	end
})

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

Re: Post your modding questions here

by ABJ » Post

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
  end
 end
}) 
Thanks it worked! Until the game crashed saying that nodedef was nil. You see, I was trying to check if the node at the specified position was walkable or not. What am I doing wrong here?

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

Re: Post your modding questions here

by Byakuren » Post

ABJ wrote:

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
  end
 end
}) 
Thanks it worked! Until the game crashed saying that nodedef was nil. You see, I was trying to check if the node at the specified position was walkable or not. What am I doing wrong here?
Your index (node) is a table. minetest.registered_nodes is indexed by node names.
Every time a mod API is left undocumented, a koala dies.

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

Re: Post your modding questions here

by sofar » Post

Byakuren wrote:
ABJ wrote:

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
  end
 end
}) 

Thanks it worked! Until the game crashed saying that nodedef was nil. You see, I was trying to check if the node at the specified position was walkable or not. What am I doing wrong here?
Your index (node) is a table. minetest.registered_nodes is indexed by node names.

specifically, replace:

Code: Select all

local nodedef = minetest.registered_nodes[node]
with

Code: Select all

local nodedef = minetest.registered_nodes[node.name]
You can also just do:

Code: Select all

minetest.set_node(pos, {name = "air"})
And even better would be:

Code: Select all

minetest.remove_node(pos)

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your modding questions here

by Gerald » Post

ABJ wrote:

Code: Select all

minetest.register_abm({
 nodenames = {"default:wood"}, 	  
 interval = 10.0, 
 chance = 1, 	
 action = function(pos, node, active_object_count, active_object_count_wider)
  local node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
  local nodedef = minetest.registered_nodes[node]
  if nodedef.walkable == true then
   minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "air"})
  end
 end
}) 
Another big improvement:
The definition of a node does [almost certainly] not change. Therefore you can check only once:

Code: Select all

if minetest.registered_nodes["default:wood"].walkable then
  minetest.register_abm({
    nodenames = {"default:wood"}, 	  
    interval = 10, 
    chance = 1, 	
    action =  minetest.remove_node
  })
end

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

Re: Post your modding questions here

by ABJ » Post

Thanks sofar and Gerald.

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

Re: Post your modding questions here

by Lejo » Post

Is there any way to let players automaticly respawning using a serverside mod?

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

I am attempting to modify the old currency mod to work with US Currency for educational purposes. I have a functional method that sort of works, but IDEALLY, I have an angle I am not sure is doable, so I turn to you, my fellow minetesters...

I want to base the entire currency on pennies, and create some sort of auto-alias system that will understand that a dollar bill is 100 pennies while being represented by a separate inv image so the player will see a dollar bill but the program will see 100 pennies.

In this way, I hope to develop shops that can ask for two quarters as payment but accept 5 dimes, or 50 pennies, or two dimes and 6 nickles - ect...

I am trying to modify the currency mod, and it works with like node placement (if I put two quarters as payment using the example above) but, of course, will reject 5 dimes... even though their values are both 50 pennies.

Does this seem doable to those in the know or am I chasing rainbows? LOL
everything can be a learning experience...

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your modding questions here

by azekill_DIABLO » Post

Code: Select all

core.register_alias dollar = 50penny
???? something like that?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

azekill_DIABLO wrote:

Code: Select all

core.register_alias dollar = 50penny
???? something like that?
Ahhhhh! It's a place to start. Core_register...
everything can be a learning experience...

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your modding questions here

by azekill_DIABLO » Post

don't follow my syntax though :)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your modding questions here

by Gerald » Post

christoferlevich wrote:I am attempting to modify the old currency mod to work with US Currency for educational purposes. I have a functional method that sort of works, but IDEALLY, I have an angle I am not sure is doable, so I turn to you, my fellow minetesters...
Can you provide a link to the currency mod you use? There are many mods of this kind.
christoferlevich wrote: I want to base the entire currency on pennies, and create some sort of auto-alias system that will understand that a dollar bill is 100 pennies while being represented by a separate inv image so the player will see a dollar bill but the program will see 100 pennies.

In this way, I hope to develop shops that can ask for two quarters as payment but accept 5 dimes, or 50 pennies, or two dimes and 6 nickles - ect...

I am trying to modify the currency mod, and it works with like node placement (if I put two quarters as payment using the example above) but, of course, will reject 5 dimes... even though their values are both 50 pennies.

Does this seem doable to those in the know or am I chasing rainbows? LOL
I think the place to integrate this feature is mainly the code of the shops.

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

azekill_DIABLO wrote:don't follow my syntax though :)
No... But the keywords to look for are golden.
everything can be a learning experience...

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

Gerald wrote: Can you provide a link to the currency mod you use? There are many mods of this kind.

The forum post appears to be deleted for the mod but it appears to be this one:
https://github.com/minetest-mods/currency
Gerald wrote:I think the place to integrate this feature is mainly the code of the shops.
I am guessing at remedies and will try either way. This would be huge for the 'teachers' if it had this functionality.
everything can be a learning experience...

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your modding questions here

by Gerald » Post

My solution is the following:
modify currency/shop.lua
  • Add a table e.g. "default.shop.replacements" to register replacements.
  • Add two inventories to the shop (see line 111) "owner_wants_adjusted" and "customers_gave_adjusted"
  • While trading go through the "owner_wants" and "cotumer_gave" inventories and copy everything to the adjusted versions if there is no replacement and replace if there is one.
  • Check for accord in the adjusted inventories. (see line 191)
  • exchange using the adjusted inventories (this is strange because everything is replaced even if it fits perfectly; The shopowner only gets pennys but there is no other simple solution) (see line 197)

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

cx384 wrote:
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)
Not exactly. It's the generation chunk size, which is 48^3 ( if i remember right)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

Re: Post your modding questions here

by Byakuren » Post

It's 80^3
Every time a mod API is left undocumented, a koala dies.

User avatar
ErrorNull
Member
Posts: 274
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: Post your modding questions here

by ErrorNull » Post

Hello, i'm going to try using nodetimers for the first time and have a few quick and basic questions. Here is an example:

Code: Select all

local nodetimer = minetest.get_node_timer(some_position)
nodetimer:start(10)

[inside node definition at 'some_position']
   on_timer = function(pos, elapsed)
      print("Hello")
   end
question #1. The timer will loop indefinitely and this will print 'hello' every 10 seconds.. is that correct?

question #2. If player walks away from 'some_position' and the mapchunk unloads, the nodetimer will stop execution and 'pause' until the mapchunk is loaded again.. is that right?

I also have a question about minetest.emerge_area(pos1, pos2) that is related:

question #3. When I call this function, the distanct mapchunk located at pos1 and pos2 will be force-loaded, therefor I can access things like node metadata and have nodetimers behave like normal. Is that right?

question #4. How long does this far-away mapchunk remain loaded? I'm assuming until server restart, then I will need to call minetest.emerge() again is that correct?

question #5. Is there a way for forcable unload a mapchunk that was loaded via minetest.emerge()?



Thank you for any clarification!

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

Re: Post your modding questions here

by Byakuren » Post

1) No. Check the documentation for on_timer: to make the timer restart you need to return true from the callback.
2) Yes
3) Not sure about node timers, but I think you can access metadata even if its block is unloaded. emerge_area however only momentarily loads the area. I'm not how long it stays loaded, my guess would be for one server frame. I would guess that node timers will be run if they are due, but I am not sure, you should test it.
4) Answered in 3; probably only for one server frame, and in any case not forever. If you want to forceload a block then use minetest.forceload_block
5) If you use minetest.forceload_block then using minetest.forceload_free_block will undo the forceload.

Be careful if you use persistent forceloads though. If each forceload isn't matched by a call to forceload_free_block, you will leak forceloaded blocks. The approach I would take is to never use persistent forceloads, and use mod storage to keep track of any persistent forceloading information. That way removing a mod will also remove its forceloads.
Every time a mod API is left undocumented, a koala dies.

User avatar
ErrorNull
Member
Posts: 274
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: Post your modding questions here

by ErrorNull » Post

thanks you fir your answers Byakuren! it seems we cannot access node Metadata on nodes that are not loaded - it's one of the reasons why I'm having to explore the emerge_area idea. one server frame sounds like a short duration. does forceload_block do the same as emerge_area? if so it may be a more flexible option as i think I'd like to have distant blocks loaded for say 10 seconds then i can use forceload_free_block.

Locked

Who is online

Users browsing this forum: No registered users and 15 guests