Post your modding questions here

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:16

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

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

Re: Post your modding questions here

by KzoneDD » Wed Jul 12, 2017 22:47

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
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 » Thu Jul 13, 2017 09:10

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
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 » Thu Jul 13, 2017 09:55

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: 2120
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Thu Jul 13, 2017 10:15

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
Location: New Hampshire U.S.A
In-game: ExeterDad

Re: Post your modding questions here

by ExeterDad » Thu Jul 13, 2017 10:30

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
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 » Thu Jul 13, 2017 14:18

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: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Thu Jul 13, 2017 17:46

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: 2060
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Fri Jul 14, 2017 19:47

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: 91
Joined: Sun Dec 28, 2014 10:35
Location: Germany
In-game: gerald7

Re: Post your modding questions here

by Gerald » Fri Jul 14, 2017 21:06

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
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
 

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

Re: Post your modding questions here

by christoferlevich » Sun Jul 16, 2017 12:03

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: 7489
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

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

Re: Post your modding questions here

by christoferlevich » Sun Jul 16, 2017 13:21

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: 7489
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

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

Re: Post your modding questions here

by Gerald » Sun Jul 16, 2017 13:57

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: 323
Joined: Thu Dec 01, 2016 23:44
Location: Athol, Massachusetts
GitHub: ChristoferL

Re: Post your modding questions here

by christoferlevich » Sun Jul 16, 2017 14:13

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: 323
Joined: Thu Dec 01, 2016 23:44
Location: Athol, Massachusetts
GitHub: ChristoferL

Re: Post your modding questions here

by christoferlevich » Sun Jul 16, 2017 14:21

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: 91
Joined: Sun Dec 28, 2014 10:35
Location: Germany
In-game: gerald7

Re: Post your modding questions here

by Gerald » Sun Jul 16, 2017 15:48

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: 779
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Post your modding questions here

by orwell » Sun Jul 16, 2017 19:54

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: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Sun Jul 16, 2017 22:04

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

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Post your modding questions here

by ErrorNull » Sun Jul 16, 2017 22:18

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: 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 17, 2017 02:18

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: 201
Joined: Thu Mar 03, 2016 00:43

Re: Post your modding questions here

by ErrorNull » Mon Jul 17, 2017 02:48

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.
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests