Post your modding questions here

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

Re: Post your modding questions here

by Don » Sun Mar 29, 2015 18:26

I am having trouble understanding how to get directions.
What I want to do is get the node to the right. I am not sure how to know the direction the player is looking and get the right or left direction. I know how to get the x, y or z direction but that doesn't work for this.
What I need is this
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 <node to the right> == "dirt" then
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
 

Kilarin
Member
 
Posts: 649
Joined: Mon Mar 10, 2014 00:36

Re: Post your modding questions here

by Kilarin » Sun Mar 29, 2015 19:37

node to the right of what? of the player, or of what they are pointing at?
 

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

Re: Post your modding questions here

by Don » Sun Mar 29, 2015 19:54

Kilarin wrote:node to the right of what? of the player, or of what they are pointing at?

node just placed.
Something like this
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
   after_place_node = function(pos, placer)
       if <node to right> == "dirt" then
          minetest.set_node({x=pos.x, y=pos.y, z=pos.z},{name = "dirt",})
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
 

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

Re: Post your modding questions here

by Hybrid Dog » Sun Mar 29, 2015 20:21

Don wrote:
Kilarin wrote:node to the right of what? of the player, or of what they are pointing at?

node just placed.
Something like this
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
   after_place_node = function(pos, placer)
       if <node to right> == "dirt" then
          minetest.set_node({x=pos.x, y=pos.y, z=pos.z},{name = "dirt",})

try this
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
   after_place_node = function(pos, placer)
      local dir = placer:get_look_dir()
      local right_pos = vector.new(pos)
      if math.abs(dir.x) < math.abs(dir.z) then
         right_pos.x = right_pos.x+dir.z/math.abs(dir.z)
      else
         right_pos.z = right_pos.z-dir.x/math.abs(dir.x)
      end
      local right_node = minetest.get_node(right_pos)
      minetest.set_node(pos, right_node)
   end,
Last edited by Hybrid Dog on Sun Mar 29, 2015 20:26, edited 1 time in total.
 

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

Re: Post your modding questions here

by Don » Sun Mar 29, 2015 20:24

Thank you.
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
Rui
Member
 
Posts: 255
Joined: Wed Oct 01, 2014 12:59
GitHub: Rui-Minetest

[DELETED]

by Rui » Mon Mar 30, 2015 12:11

[DELETED]
Last edited by Rui on Fri Nov 04, 2016 12:53, edited 1 time in total.
 

User avatar
12Me21
Member
 
Posts: 826
Joined: Tue Mar 05, 2013 00:36

Re: Post your modding questions here

by 12Me21 » Mon Mar 30, 2015 12:38

Rui wrote:Without utilizing the light source, Is there a way to change the brightness of the air?


I think the only way to do that is to do
light_source = #,

unless you mean the light from the sun...
 

User avatar
Rui
Member
 
Posts: 255
Joined: Wed Oct 01, 2014 12:59
GitHub: Rui-Minetest

[DELETED]

by Rui » Wed Apr 01, 2015 15:28

[DELETED]
Last edited by Rui on Fri Nov 04, 2016 12:54, edited 1 time in total.
 

User avatar
Rui
Member
 
Posts: 255
Joined: Wed Oct 01, 2014 12:59
GitHub: Rui-Minetest

[DELETED]

by Rui » Wed Apr 01, 2015 15:30

[DELETED]
Last edited by Rui on Fri Nov 04, 2016 12:54, edited 1 time in total.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Wed Apr 01, 2015 16:13

You need to define a node with:
drawtype = "airlike"
walkable = false
paramtype = "light"
light_source = 14 (or whatever level you prefer)
 

User avatar
Rui
Member
 
Posts: 255
Joined: Wed Oct 01, 2014 12:59
GitHub: Rui-Minetest

[DELETED]

by Rui » Wed Apr 01, 2015 16:48

[DELETED]
Last edited by Rui on Fri Nov 04, 2016 12:54, edited 1 time in total.
I speak Engrish.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Wed Apr 01, 2015 21:05

Also needs:
sunlight_propagates = true
buildable_to = true
pointable = false
diggable = false
These nodes may have to be placed and removed by code not the player.
See the 'mini-sun / pseudo light source' mod.
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Wed Apr 01, 2015 21:32

Can some one give me an example of how to use this in a mod:

"force_facedir: if true, forcefully reset the facedir to north when placing on the floor or ceiling"

I have tried to do it in node registration but it asks for a name and parameters;
I assumed it needed the node name but it says its expecting parameters
and I dont know what to do next.
 

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

Re: Post your modding questions here

by Hybrid Dog » Thu Apr 02, 2015 09:53

paramat wrote:Also needs:
sunlight_propagates = true
buildable_to = true
pointable = false
diggable = false
These nodes may have to be placed and removed by code not the player.
See the 'mini-sun / pseudo light source' mod.

you could also use table.copy(minetest.registered_nodes.air)

Napiophelios wrote:Can some one give me an example of how to use this in a mod:

"force_facedir: if true, forcefully reset the facedir to north when placing on the floor or ceiling"

I have tried to do it in node registration but it asks for a name and parameters;
I assumed it needed the node name but it says its expecting parameters
and I dont know what to do next.

minetest.set_node(pos, {name="default:mese", param2=0}
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Fri Apr 03, 2015 04:12

Hybrid Dog wrote:
Napiophelios wrote:Can some one give me an example of how to use this in a mod:

"force_facedir: if true, forcefully reset the facedir to north when placing on the floor or ceiling"

I have tried to do it in node registration but it asks for a name and parameters;
I assumed it needed the node name but it says its expecting parameters
and I dont know what to do next.

minetest.set_node(pos, {name="default:mese", param2=0}


Okay I used :

on_place= minetest.set_node({name = "minim:shaftbomb", param2=1}),

and the node is successfully placed facing "north" each time,
but it only works if I disable: paramtype2 = "facedir",

As is, a screwdriver doesnt actually turn the node (but the node does function as if it were turned).

Each side of the node depending on it facedir determines the depth/direction of the explosion;

so the player needs to see the turned node when turned by a screwdriver
because the textures are the indicators of depth and direction

and it has to be placed the same each time to give the indicators proper orientation
no matter from what direction they are placed by the player.

what am I missing?
 

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

Re: Post your modding questions here

by Hybrid Dog » Fri Apr 03, 2015 12:05

Napiophelios wrote:
Hybrid Dog wrote:
Napiophelios wrote:Can some one give me an example of how to use this in a mod:

"force_facedir: if true, forcefully reset the facedir to north when placing on the floor or ceiling"

I have tried to do it in node registration but it asks for a name and parameters;
I assumed it needed the node name but it says its expecting parameters
and I dont know what to do next.

minetest.set_node(pos, {name="default:mese", param2=0}


Okay I used :

on_place= minetest.set_node({name = "minim:shaftbomb", param2=1}),

after_place_node = function(pos, player)
if player:get_player_control().sneak then
minetest.set_node(pos, {name="minim:shaftbomb", param2=0}
end
end,
 

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

Re: Post your modding questions here

by Don » Fri Apr 03, 2015 15:48

Can you get the direction of a node and place a new node facing the same direction with an abm?

This is what I want
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
minetest.register_abm({
   nodenames = {"mymod:node1"},
   interval = 1,
   chance = 1,
   action = function(pos, node)
      local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name


      if node == "air" then
         minetest.set_node(pos,{name = "mymod:node2"})
      end
   end,
})

When node 2 is placed I want it to face the same direction as what node 1 was placed.
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
 

TeTpaAka
Member
 
Posts: 131
Joined: Sat Dec 28, 2013 21:54

Re: Post your modding questions here

by TeTpaAka » Fri Apr 03, 2015 16:09

Don wrote:Can you get the direction of a node and place a new node facing the same direction with an abm?

This is what I want
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
minetest.register_abm({
   nodenames = {"mymod:node1"},
   interval = 1,
   chance = 1,
   action = function(pos, node)
      local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name


      if node == "air" then
         minetest.set_node(pos,{name = "mymod:node2"})
      end
   end,
})

When node 2 is placed I want it to face the same direction as what node 1 was placed.


You have to set the param2 of the new node to the same value as of the old one. So you would have to
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
minetest.set_node(pos, {name = "mymod:node2", param2 = node.param2})

untested, see lua_api.txt

By the way, you shouldn't name your variable to the same name as a function variable with a different type.
 

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

Re: Post your modding questions here

by Don » Fri Apr 03, 2015 16:26

Thank you. Works like it should.
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
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Sat Apr 04, 2015 03:12

Hybrid Dog wrote:after_place_node = function(pos, player)
if player:get_player_control().sneak then
minetest.set_node(pos, {name="minim:shaftbomb", param2=0}
end
end,


Thanks man that did trick :)
 

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

Which node face tile is which?

by ABJ » Mon Apr 06, 2015 11:47

I want to make my own nodes so I need to know which node faces are which on the init.lua code. I know there are 6 faces but I don't know which face is which side so I can't correctly texture. If you would explain this like (face 1=up face 2=down etc) way, It would be very helpful
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Mon Apr 06, 2015 12:03

I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

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

Re: Which node face tile is which?

by Hybrid Dog » Mon Apr 06, 2015 14:07

ABJ wrote:I want to make my own nodes so I need to know which node faces are which on the init.lua code. I know there are 6 faces but I don't know which face is which side so I can't correctly texture. If you would explain this like (face 1=up face 2=down etc) way, It would be very helpful

http://dev.minetest.net/register_node#Node_definition
https://github.com/minetest/minetest/bl ... .txt#L2967
 

User avatar
12Me21
Member
 
Posts: 826
Joined: Tue Mar 05, 2013 00:36

Re: Post your modding questions here

by 12Me21 » Mon Apr 06, 2015 20:24

Is there any way to play sounds without using minetest.sound_play?
It's extremely limited (you could do more with command blocks in minecraft)
 

User avatar
12Me21
Member
 
Posts: 826
Joined: Tue Mar 05, 2013 00:36

Re: Post your modding questions here

by 12Me21 » Mon Apr 06, 2015 20:56

I need help making a node that will play MML songs. There's only ONE lua MML player in existence, but IDK if it will work in minetest (probably not). https://github.com/legospacy/lua-mml/bl ... er/mml.lua

Here's my code so far: (without the music playing 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
function play_song (pos, fields.sq1, fields.sq2, fields.tri, fields.nsg, fields.tmp)

end

minetest.register_node("mml:nes", {
   description = "NES",
   tiles = {"default_glass.png"},
   paramtype = "light",
   sunlight_propagates = true,
   groups = {oddly_breakable_by_hand=3},
   on_construct = function(pos)
      local meta = minetest.get_meta(pos)
      meta:set_string("sq2", "")
      meta:set_string("sq1", "")
      meta:set_string("tri", "")
      meta:set_string("nsg", "")
      meta:set_string("tmp", "5")
      meta:set_string("formspec", "size[13,16]"..
         "field[1, 1;11,2;sq1; Square Wave 1 ;]".. --[1]
         "field[1, 4;11,2;sq2; Square Wave 2 ;]".. --[2]
         "field[1, 7;11,2;tri; Triangle Wave ;]".. --/\
         "field[1,10;11,2;nsg;Noise Generator;]".. --XZ
         "field[1,13;5,2;tmp;Tempo:;]"..
         "button_exit[7,13;5,2;set;Set]")
      meta:set_string("infotext", "Unprogrammed NES")
   end,
   on_receive_fields = function(pos, formname, fields, sender)
      local meta = minetest.get_meta(pos)
      
      meta:set_string("sq2", fields.sq2)
      meta:set_string("sq1", fields.sq1)
      meta:set_string("tri", fields.tri)
      meta:set_string("nsg", fields.nsg)
      meta:set_string("tmp", fields.tmp)
      atkstr = "size[13,16]"
      if fields.sq1 ~= nil then
      atkstr = atkstr.."field[1, 1;11,2;sq1; Square Wave 1 ;"..minetest.formspec_escape(fields.sq1).."]"
      end
      if fields.sq2 ~= nil then
      atkstr = atkstr.."field[1, 4;11,2;sq2; Square Wave 2 ;"..minetest.formspec_escape(fields.sq2).."]"
      end
      if fields.tri ~= nil then
      atkstr = atkstr.."field[1, 7;11,2;tri; Triangle Wave ;"..minetest.formspec_escape(fields.tri).."]"
      end
      if fields.nsg ~= nil then
      atkstr = atkstr.."field[1,10;11,2;nsg;Noise Generator;"..minetest.formspec_escape(fields.nsg).."]"
      end
      if fields.tmp ~= nil then
      atkstr = atkstr.."field[1,13;5,2;tmp;Tempo:;"..         minetest.formspec_escape(fields.tmp).."]"
      end
      atkstr=atkstr.."button_exit[7,13;5,2;set;Set]"
      meta:set_string("formspec", atkstr)
      meta:set_string("infotext", "Programmed NES")
   end,
   on_punch = play_song(pos, fields.sq1, fields.sq2, fields.tri, fields.nsg, fields.tmp)
})


 

ancient_spirit
New member
 
Posts: 4
Joined: Fri Apr 03, 2015 12:25
In-game: ancient_spirit

Re: Post your modding questions here

by ancient_spirit » Tue Apr 07, 2015 23:28

How can I script a node to spawn next to another in a set pattern? I'm trying to make a plant that grows.
I'm a rookie programmer, so please keep things simple. Thanks in advance.
 

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

Re: Post your modding questions here

by Don » Tue Apr 07, 2015 23:35

ancient_spirit wrote:How can I script a node to spawn next to another in a set pattern? I'm trying to make a plant that grows.
I'm a rookie programmer, so please keep things simple. Thanks in advance.

You could do it in an abm
http://dev.minetest.net/ABM
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
Rui
Member
 
Posts: 255
Joined: Wed Oct 01, 2014 12:59
GitHub: Rui-Minetest

[DELETED]

by Rui » Wed Apr 08, 2015 08:54

[DELETED]
Last edited by Rui on Fri Nov 04, 2016 12:54, edited 1 time in total.
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Wed Apr 08, 2015 21:46

I want to create a node that can only be placed on the trunk of a tree, its for collection sap to make into sugar, I can't seem to figure out the code I would need. I just need to check what node I placed the object against, it's wallmounted, and then make sure its default:tree, would also like to check nodes above and below to make sure it's actually a tree and not just a random piece of tree.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
12Me21
Member
 
Posts: 826
Joined: Tue Mar 05, 2013 00:36

Re: Post your modding questions here

by 12Me21 » Wed Apr 08, 2015 22:17

Nathan.S wrote:I want to create a node that can only be placed on the trunk of a tree, its for collection sap to make into sugar, I can't seem to figure out the code I would need. I just need to check what node I placed the object against, it's wallmounted, and then make sure its default:tree, would also like to check nodes above and below to make sure it's actually a tree and not just a random piece of tree.

you'd have to make an on_place function.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron