Post your modding questions here

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 Jul 29, 2016 23:44

Meta entries have no type, everything is saved as string. So set_int(1) is the same as set_string("1")

And get_int does tonumber(get_string(k))
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Sat Jul 30, 2016 00:22

What in the world are "special_tiles" in the node def?
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sat Jul 30, 2016 13:03

pithy wrote:What in the world are "special_tiles" in the node def?


http://dev.minetest.net/minetest.register_node

special_tiles — Specifies certain textures used in things like texture animations. (like flowing liquids)
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sat Jul 30, 2016 13:08

I'm having a hard time with writing an on_punch function - can someone look this over and tell me where I goofed?

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
on_punch = function(pos, node, puncher)
      local name = puncher:get_player_name()
      local inv = meta:get_inventory()
      if inv:is_empty("src") then
         minetest.chat_send_player(name,"It is empty!")
         return true
      elseif not inv:is_empty("dst") then
         minetest.chat_send_player(name,"It is full!")
         return true
      end
      return true
end


Both 'src' and 'dst' are 3x3 in the formspec, and this is just a pre-usage check of the item - but I can't get this part to work properly. Any help would be appreciated!
 

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 » Sat Jul 30, 2016 13:09

local inv = meta:get_inventory()

What meta are you getting? Try get_inventory(pos).
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sat Jul 30, 2016 13:47

Tried that - nope, still won't talk to me. Tried this change to 'return', based on the (working) can_dig function:

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
   on_construct = function(pos)
      local meta = minetest.env:get_meta(pos)
      meta:set_string("formspec",formspec)
      meta:set_string("infotext", "It!")
      local inv = meta:get_inventory()
      inv:set_size("src", 9)
      inv:set_size("dst", 9)
   end,
   can_dig = function(pos,player)
      local meta = minetest.env:get_meta(pos);
      local inv = meta:get_inventory()
      if not inv:is_empty("src") then
         return false
      elseif not inv:is_empty("dst") then
         return false
      end
      return true
   end,
})
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Jul 30, 2016 14:37

Hi, I want to ask a bunch of questions, but I don't want to interrupt the current discussion. Sorry if this looks like spam. I will post more when this problem is laid to rest.
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Sat Jul 30, 2016 16:10

KCoombes wrote:
pithy wrote:What in the world are "special_tiles" in the node def?


http://dev.minetest.net/minetest.register_node

special_tiles — Specifies certain textures used in things like texture animations. (like flowing liquids)

all that link says about special_tiles is "This text needs further expansion"
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Jul 30, 2016 17:48

That is one of the most annoying things in a wiki. Just as you think you're finally gonna figure out what this awesome function does, BAM! Stub.
I really wish and hope that somebody who is knowledgeable in this field and has the explaining skills of rubenwardy would expand all those incomplete wiki pages (and ruben's book btw).
 

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 » Sat Jul 30, 2016 19:34

minetest.env is deprecated
on_construct is not where to do node metadata manipulation, only to initialize. Use on_place or after_place_node instead.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sat Jul 30, 2016 22:12

everamzah wrote:minetest.env is deprecated --changed to minetest.
on_construct is not where to do node metadata manipulation, only to initialize. Use on_place or after_place_node instead.


--changed to on_place

This is now working - thanks for your help!
Last edited by KCoombes on Sun Jul 31, 2016 00:45, edited 1 time in total.
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sat Jul 30, 2016 23:57

rubenwardy wrote:After exporting an obj from NBE, you should take it to a UV wrapping program such as Blender. If you don't need to UV wrap it, just export it as a node box


I just created a 3x5 node..., ummm,node using NBE, and it works just fine without even using the .obj models anywhere... just the dimensions which NBE produced.
The only issue I am having at the moment, is figuring out why I fall through it when I walk over it... yet I cannot pass through it if it is placed upright, or from the sides either upright or laying down?
Other than that issue, everything else works fine, just a simple 16x16px texture repeats on it well.

I wonder if I add the .obj models if that will solve my falling through problem when walking over the large node?
Flick?... Flick who?
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Sun Jul 31, 2016 01:19

TumeniNodes wrote:
rubenwardy wrote:After exporting an obj from NBE, you should take it to a UV wrapping program such as Blender. If you don't need to UV wrap it, just export it as a node box


I just created a 3x5 node..., ummm,node using NBE, and it works just fine without even using the .obj models anywhere... just the dimensions which NBE produced.
The only issue I am having at the moment, is figuring out why I fall through it when I walk over it... yet I cannot pass through it if it is placed upright, or from the sides either upright or laying down?
Other than that issue, everything else works fine, just a simple 16x16px texture repeats on it well.

I wonder if I add the .obj models if that will solve my falling through problem when walking over the large node?


A .obj does not have a collision_box.
 

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 » Sun Jul 31, 2016 02:20

TumeniNodes wrote:
rubenwardy wrote:After exporting an obj from NBE, you should take it to a UV wrapping program such as Blender. If you don't need to UV wrap it, just export it as a node box


I just created a 3x5 node..., ummm,node using NBE, and it works just fine without even using the .obj models anywhere... just the dimensions which NBE produced.
The only issue I am having at the moment, is figuring out why I fall through it when I walk over it... yet I cannot pass through it if it is placed upright, or from the sides either upright or laying down?
Other than that issue, everything else works fine, just a simple 16x16px texture repeats on it well.

I wonder if I add the .obj models if that will solve my falling through problem when walking over the large node?


By dimension it produced, do you mean the node box export? You don't have to copy the co-ords manually, you could use file > export > standalone lua file
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jul 31, 2016 03:01

rubenwardy wrote:By dimension it produced, do you mean the node box export? You don't have to copy the co-ords manually, you could use file > export > standalone lua file


Exactically... :D
Yes, I already use that feature but, since I am throwing it into a mod with a few other items..., what I normally do is this:
export standalone Lua, then export ,obj, and then save project as...
I then copy the node dimensions into my init.lua code.
Just recently with this mod..., I import the .obj into Blender, fix the normals (if needed), set textures if required, etc., export the new.obj, and save as a .blend and put them both into the models folder, whether needed or not..., so that they are available as part of the source, for others to tinker with, if they desire, in the future. (it seems like a good idea to me that this should be normal practice)

The only issue I have had with NBE (which is a minor issue) is when opening a past .nbe file..., the nodes are offset and when you click to drag they jump. I have been able to manage the problem, myself but... sometimes it can be an annoyance.
Flick?... Flick who?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jul 31, 2016 03:04

pithy wrote:
KCoombes wrote:
pithy wrote:What in the world are "special_tiles" in the node def?


http://dev.minetest.net/minetest.register_node

special_tiles — Specifies certain textures used in things like texture animations. (like flowing liquids)

all that link says about special_tiles is "This text needs further expansion"


They also often have a comment, mentioning "mostly unused" :P
Flick?... Flick who?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jul 31, 2016 03:07

pithy wrote:A .obj does not have a collision_box.


right so... is it possible to then activate the .obj "drawtype = mesh
and then, set the entire object dimensions as "collision_box"
and then set the selection_box dimension in a small convenient location on the object?
Would that work so I can finally walk across this danged thing without falling through it?
Flick?... Flick who?
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sun Jul 31, 2016 12:16

TumeniNodes wrote:
pithy wrote:A .obj does not have a collision_box.


right so... is it possible to then activate the .obj "drawtype = mesh
and then, set the entire object dimensions as "collision_box"
and then set the selection_box dimension in a small convenient location on the object?
Would that work so I can finally walk across this danged thing without falling through it?


Yes, as long as you set walkable = true in the node definition
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Jul 31, 2016 14:12

Topic: Can you build high enough to have your blocks not cast shadows??
Reason: I want to make another dimesion(and possibly more than just one). I'm hoping to stack one on top the other, but i don't know how high or even if i can do so.
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sun Jul 31, 2016 14:18

ozkur wrote:Topic: Can you build high enough to have your blocks not cast shadows??

You must teleport yourself about 1000 nodes up or down and build there (try using WorldEdit, it really helps). This distance is to make sure that the mapblocks in between are not generated/loaded so the light can not be updated there.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Jul 31, 2016 14:35

Krock wrote:
ozkur wrote:Topic: Can you build high enough to have your blocks not cast shadows??

You must teleport yourself about 1000 nodes up or down and build there (try using WorldEdit, it really helps). This distance is to make sure that the mapblocks in between are not generated/loaded so the light can not be updated there.


Thanks!
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sun Jul 31, 2016 14:51

InvRef question:

remove_item("listname", stack)
take as many items as specified from the list, returns the items that were actually removed (as an ItemStack)

Ok, so this means 'take as many (items = stack) as specified from the (list = listname) - what is the 'as specified' part?
and what exactly does 'returns the items that were actually removed' mean? Gives the items back? Seems counter to the process of removing the item in the first place!
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sun Jul 31, 2016 15:21

KCoombes wrote:Iwhat exactly does 'returns the items that were actually removed' mean? Gives the items back?


It removes the specified stack from a collection of stacks (= list)
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 stack = "default:stick 3"
-- OR: stack = ItemStack("default:stick 3")

-- Try to remove the items specified in "stack" from the list "main"
local removed_items = inv:remove_item("main", stack)
if removed_items:get_count() < stack:get_count() then
   -- Failed to remove all items: Removed only "removed_items:get_count()" of them
end
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Sun Jul 31, 2016 15:53

KCoombes wrote:InvRef question:

remove_item("listname", stack)
take as many items as specified from the list, returns the items that were actually removed (as an ItemStack)

Ok, so this means 'take as many (items = stack) as specified from the (list = listname) - what is the 'as specified' part?
and what exactly does 'returns the items that were actually removed' mean? Gives the items back? Seems counter to the process of removing the item in the first place!


The method returns an ItemStack of the things that were removed. Not returning to the inventory, returning as in calling the method evaluates to the ItemStack.
Every time a mod API is left undocumented, a koala dies.
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Jul 31, 2016 15:57

is there a way to make it so that if you step on something it replaces it self with a different block?
i want to make it so that you can step on a block, and it will have foot prints
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sun Jul 31, 2016 16:29

This code works, kinda - the 'dst' is 3x3, while the code reads only the first slot - how can I make it read all the slots?

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
      if inv:is_empty("src") then
         minetest.chat_send_player(name,"It is empty!")
      elseif not inv:is_empty("dst") then
         minetest.chat_send_player(name,"It is full!")
      end
 

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 » Sun Jul 31, 2016 18:04

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
for _, v in pairs(inv:get_list("src")) do
  print(v)
end


That might not actually work, I'm terrible with for loops.

Myself, I'm trying to throw a ball. I'm cheating a bit because I haven't looked anything up yet, but if anyone wants to clue me in on how to adjust velocity/acceleration to mimic a small heavy object, please do!

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 def = {
   name = "grenade:explosion",
   description = "Grenade Explosion (you hacker you!)",
   radius = 3,
   tiles = {
      side = "default_dirt.png",
      top = "default_dirt.png",
      bottom = "default_dirt.png",
      burning = "default_dirt.png"
   },
}

tnt.register_tnt(def)



minetest.register_craftitem("grenade:grenade", {
   description = "Grenade",
   inventory_image = "default_coal_lump.png",
   on_use = function(itemstack, user, pointed_thing)
      local v = user:get_look_dir()
      local pos = user:getpos()
      pos.y = pos.y + 1.2

      local obj = minetest.add_entity(pos, "grenade:grenade")
      obj:setvelocity({x = v.x * 4, y = v.y * 2 + 4, z = v.z * 4})
      obj:setacceleration({x = v.x / 4, y = v.y / 2 - 4, z = v.z / 4})

      itemstack:take_item()
      return itemstack
   end,
})

minetest.register_entity("grenade:grenade", {
   physical = true,
   collide_with_objects = true,
   weight = 5,
   textures = {"default_coal_lump.png"},
   on_activate = function(self, staticdata)
      self.timer = 0
   end,
   on_step = function(self, dtime)
      local acc = self.object:getacceleration()
      self.object:setacceleration({x = acc.x * 2 / 4, y = acc.y, z = acc.z * 2 / 4})

      self.timer = self.timer + dtime
      if self.timer > 4 then
         tnt.boom(self.object:getpos(), def)
      end
   end,
})


https://github.com/everamzah/grenade
 

Hasan
Member
 
Posts: 30
Joined: Mon Oct 12, 2015 14:50
IRC: Hasan2

Re: Post your modding questions here

by Hasan » Sun Jul 31, 2016 19:37

Hello, is it possible to get the node direction as a number, example: the node direction at the point (0,0,0) is (-270)
is it possible to get this?
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Mon Aug 01, 2016 05:35

everamzah wrote:
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
for _, v in pairs(inv:get_list("src")) do
  print(v)
end


That might not actually work, I'm terrible with for loops.

Myself, I'm trying to throw a ball. I'm cheating a bit because I haven't looked anything up yet, but if anyone wants to clue me in on how to adjust velocity/acceleration to mimic a small heavy object, please do!

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 def = {
   name = "grenade:explosion",
   description = "Grenade Explosion (you hacker you!)",
   radius = 3,
   tiles = {
      side = "default_dirt.png",
      top = "default_dirt.png",
      bottom = "default_dirt.png",
      burning = "default_dirt.png"
   },
}

tnt.register_tnt(def)



minetest.register_craftitem("grenade:grenade", {
   description = "Grenade",
   inventory_image = "default_coal_lump.png",
   on_use = function(itemstack, user, pointed_thing)
      local v = user:get_look_dir()
      local pos = user:getpos()
      pos.y = pos.y + 1.2

      local obj = minetest.add_entity(pos, "grenade:grenade")
      obj:setvelocity({x = v.x * 4, y = v.y * 2 + 4, z = v.z * 4})
      obj:setacceleration({x = v.x / 4, y = v.y / 2 - 4, z = v.z / 4})

      itemstack:take_item()
      return itemstack
   end,
})

minetest.register_entity("grenade:grenade", {
   physical = true,
   collide_with_objects = true,
   weight = 5,
   textures = {"default_coal_lump.png"},
   on_activate = function(self, staticdata)
      self.timer = 0
   end,
   on_step = function(self, dtime)
      local acc = self.object:getacceleration()
      self.object:setacceleration({x = acc.x * 2 / 4, y = acc.y, z = acc.z * 2 / 4})

      self.timer = self.timer + dtime
      if self.timer > 4 then
         tnt.boom(self.object:getpos(), def)
      end
   end,
})


https://github.com/everamzah/grenade


For a heavy object, air resistance won't matter much so you can use a flat acceleration (9.8 m/s^s or whatever) and get a good approximation.
Every time a mod API is left undocumented, a koala dies.
 

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

by Hybrid Dog » Mon Aug 01, 2016 08:56

l constantly get this error message: WARNING[Server]: Deprecated call to "get_entity_name
l don't know why there's just one quote in the message…
How can l get the entity name without using get_entity_name?
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 71 guests

cron