LUA code questions

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Fri Sep 27, 2013 18:17

Mossmanikin wrote:
wcwyes wrote:how do i get a tool to place a node then disappear?


I'd do it 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
on_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    return itemstack
end,

It seems to be good except I lose tools that way how do I make sure there's air there?
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Fri Sep 27, 2013 20:08

I tried
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    local dir = pointed_thing.under.param2
        facedir = true
    return itemstack
end,

It doesn't seem to affect anything

wcwyes wrote:not exactly sure of the argument that facedir is doing in paramtype2 to be able to fill in the blanks
sorry I'm kind of new at lua
LionsDen wrote:When the tool is used, I think that below will work. If not exactly then something close. I haven't tested this code but I did adapt it from some code that I wrote that did something a little different. Because I haven't tested it, you might want to.
This goes into the node definition code.

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_use = function(itemstack, user, pointed_thing)
          --   pointed_thing.under is the object itself, can be nil.
          --   pointed_thing.above is the object above the pointed thing, can be nil.
          --   pointed_thing.type is nil if nothing is there, node if it is a node and
          --        object if it is an object.
          if pointed_thing.under then
               local dir = pointed_thing.under.param2
               --   Whatever you want to happen here.
          end
     end,
Last edited by wcwyes on Fri Sep 27, 2013 20:10, edited 1 time in total.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Sat Sep 28, 2013 17:42

I tried above under and below, above and under seem to have no affect and below seems to crash minetest
Hybrid Dog wrote:
wcwyes wrote:I tried
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    local dir = pointed_thing.under.param2
        facedir = true
    return itemstack
end,

It doesn't seem to affect anything

wcwyes wrote:not exactly sure of the argument that facedir is doing in paramtype2 to be able to fill in the blanks
sorry I'm kind of new at lua
try pointed_thing.above
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Sat Sep 28, 2013 17:48

wcwyes wrote:I tried above under and below, above and under seem to have no affect and below seems to crash minetest
Hybrid Dog wrote:
wcwyes wrote:I tried
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    local dir = pointed_thing.under.param2
        facedir = true
    return itemstack
end,

It doesn't seem to affect anything

try pointed_thing.above


I see that you are reading the facedir of the node you are pointing at but you are not doing anything with it that I can see. Maybe that is your problem. If you want the new node you are placing to have the same facedir as the pointed_thing then you need to set it. Plus I'm not sure if you can use facedir and not have it be messed up. It might be a global function or variable. Try using a different name like mymod_facedir or something. Hope this helps some.

EDIT: The way it works, the under is the actual pointed_thing while above is the node above the one pointed to.
Last edited by LionsDen on Sat Sep 28, 2013 17:49, edited 1 time in total.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Sat Sep 28, 2013 20:15

LionsDen wrote:
wcwyes wrote:I tried above under and below, above and under seem to have no affect and below seems to crash minetest
Hybrid Dog wrote:try pointed_thing.above


I see that you are reading the facedir of the node you are pointing at but you are not doing anything with it that I can see. Maybe that is your problem. If you want the new node you are placing to have the same facedir as the pointed_thing then you need to set it. Plus I'm not sure if you can use facedir and not have it be messed up. It might be a global function or variable. Try using a different name like mymod_facedir or something. Hope this helps some.

The way it works, the under is the actual pointed_thing while above is the node above the one pointed to.

The experience I've had is that facedir tells a node to orient itself the direction that you are pointed. I'm trying to apply this concept to my node/tool I need it to be a tool in my inventory but a node on the ground. I just need the node placed to orient itself the direction I'm pointing. If I knew how the code worked on nodes I wouldn't be on here. I don't know what to tell it to do because until now I thought facedir told it to do something.EDIT:could this help
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
pvect=user:get_look_dir()
Last edited by wcwyes on Sat Sep 28, 2013 20:23, edited 1 time in total.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

by Wuzzy » Sat Sep 28, 2013 20:41

How do I use LuaVoxelManip?

Note: I have no idea how it works, I studied examples and lua_api.txt but that didn’t really help. I also fear that, even if I understood the example, I would possibly only know “half the truth”. This component seems complicated.

Note 2: I know, I already asked this question. But since nobody answered and this thread seems appropriate, too, I try my luck here.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Sun Sep 29, 2013 06:15

wcwyes wrote:
LionsDen wrote:
wcwyes wrote:I tried above under and below, above and under seem to have no affect and below seems to crash minetest


I see that you are reading the facedir of the node you are pointing at but you are not doing anything with it that I can see. Maybe that is your problem. If you want the new node you are placing to have the same facedir as the pointed_thing then you need to set it. Plus I'm not sure if you can use facedir and not have it be messed up. It might be a global function or variable. Try using a different name like mymod_facedir or something. Hope this helps some.

The way it works, the under is the actual pointed_thing while above is the node above the one pointed to.

The experience I've had is that facedir tells a node to orient itself the direction that you are pointed. I'm trying to apply this concept to my node/tool I need it to be a tool in my inventory but a node on the ground. I just need the node placed to orient itself the direction I'm pointing. If I knew how the code worked on nodes I wouldn't be on here. I don't know what to tell it to do because until now I thought facedir told it to do something.EDIT:could this help
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
pvect=user:get_look_dir()


If you want to try to download this little modification I made to the lights+ mod

https://forum.minetest.net/viewtopic.php?pid=99366#p99366

I use facedir in that a little and may help somewhat. As far as the player facedir goes, they added to the function for the 0.4.8 version so that it now includes the y direction but I still haven't quite figured it all out yet. To get any further than this, you will most likely need to get answers from the prolific mod authors that have a bit more knowledge than I do.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Sun Sep 29, 2013 12:39

LionsDen wrote:
wcwyes wrote:
LionsDen wrote:
I see that you are reading the facedir of the node you are pointing at but you are not doing anything with it that I can see. Maybe that is your problem. If you want the new node you are placing to have the same facedir as the pointed_thing then you need to set it. Plus I'm not sure if you can use facedir and not have it be messed up. It might be a global function or variable. Try using a different name like mymod_facedir or something. Hope this helps some.

The way it works, the under is the actual pointed_thing while above is the node above the one pointed to.

The experience I've had is that facedir tells a node to orient itself the direction that you are pointed. I'm trying to apply this concept to my node/tool I need it to be a tool in my inventory but a node on the ground. I just need the node placed to orient itself the direction I'm pointing. If I knew how the code worked on nodes I wouldn't be on here. I don't know what to tell it to do because until now I thought facedir told it to do something.EDIT:could this help
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
pvect=user:get_look_dir()


If you want to try to download this little modification I made to the lights+ mod

https://forum.minetest.net/viewtopic.php?pid=99366#p99366

I use facedir in that a little and may help somewhat. As far as the player facedir goes, they added to the function for the 0.4.8 version so that it now includes the y direction but I still haven't quite figured it all out yet. To get any further than this, you will most likely need to get answers from the prolific mod authors that have a bit more knowledge than I do.

I only see wallmounted used in that. also I'm stuck in 4.7 for now the server owner that I admin on won't upgrade until the release is stable. Another note I'm trying to use a similar function to facedir to a tool that places a node and that's where I have the problem.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Sun Sep 29, 2013 12:54

Mossmanikin wrote:
wcwyes wrote:how do i get a tool to place a node then disappear?


I'd do it 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
on_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    return itemstack
end,

I'm thinking someething like this will take care of my lost node/tools
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    if pointed_thing.above = default:air then
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   else nil
end,
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Sun Sep 29, 2013 18:24

Wuzzy wrote:How do I use LuaVoxelManip?

The best approach to understand it is to take a look at mods that make usage of the LuaVoxelManip. PilzAdam has made a version of his nether mod that uses LuaVoxelManip: see this commit. Nore has written a simple sample mapgen for my villages mod here. While that simple example may not really be used as a full mapgen for a world you'd want to play in, it does demonstrate how LuaVoxelManip can be used.
Perhaps you can tell us what you plan to do with it? LuaVoxelManip may not be the solution to all problems. It's very efficient for huge-scale manipulation (like mapgen).
A list of my mods can be found here.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Sun Sep 29, 2013 18:28

wcwyes wrote:I only see wallmounted used in that. also I'm stuck in 4.7 for now the server owner that I admin on won't upgrade until the release is stable. Another note I'm trying to use a similar function to facedir to a tool that places a node and that's where I have the problem.


The facedir of the node being replaced in the on punch function is where I use it there. If I were to do it again, I would make it part of the node function but I was just modifying someone else's code at the time to make it work because someone wanted the new version and only the old version was available so I had to learn how to do it and make the changes to the old code. I didn't do a complete rewrite of the code but I did do some of the facedir code there. Plus when you place a node, there is a way to place it as though the player were placing it so it sort of does an auto facedir on the node being placed as long as the node does have a facedir.

EDIT: As for removing the tool, I haven't done anything like that yet in my modding so I can't really help with that part of the code.
Last edited by LionsDen on Sun Sep 29, 2013 18:29, edited 1 time in total.
 

User avatar
Mossmanikin
Member
 
Posts: 599
Joined: Sun May 19, 2013 16:26

by Mossmanikin » Sun Sep 29, 2013 20:20

wcwyes wrote:
Mossmanikin wrote:
wcwyes wrote:how do i get a tool to place a node then disappear?


I'd do it 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
on_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    return itemstack
end,

I'm thinking someething like this will take care of my lost node/tools
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    if pointed_thing.above = default:air then
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   else nil
end,


I'm not sure if I fully understand what you're trying to do...
If you don't want the tool to disappear, you should remove the line
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
itemstack:take_item()

If you want to check for air, you could try replacing the line
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 pointed_thing.above = default:air then

with
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 minetest.get_node(pt.above).name=="air" then

(didn't test it)
furthermore I'd replace
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
else nil

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

Noob 4 life!
My stuff
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Mon Sep 30, 2013 02:07

Mossmanikin wrote:
wcwyes wrote:
Mossmanikin wrote:
I'd do it 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
on_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
    itemstack:take_item()
    return itemstack
end,

I'm thinking someething like this will take care of my lost node/tools
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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    if pointed_thing.above = default:air then
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   else nil
end,


I'm not sure if I fully understand what you're trying to do...
If you don't want the tool to disappear, you should remove the line
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
itemstack:take_item()

If you want to check for air, you could try replacing the line
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 pointed_thing.above = default:air then

with
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 minetest.get_node(pt.above).name=="air" then

(didn't test it)
furthermore I'd replace
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
else nil

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

I want the tool to disappear only if it places a node with the current code it places a node regardless if there is a node already there or not. If there is one the game rejects the node and the tool is still removed. so i want to check for air so the tool will not try to place the node and thus removing itself.
Last edited by wcwyes on Mon Sep 30, 2013 02:07, edited 1 time in total.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Mon Sep 30, 2013 20:13

I did try the following and got the error <code>attempt to index global 'pt'(a nil value)</code>
Mossmanikin wrote:If you want to check for air, you could try replacing the line
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 pointed_thing.above = default:air then

with
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 minetest.get_node(pt.above).name=="air" then

(didn't test it)
furthermore I'd replace
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
else nil

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

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Mon Sep 30, 2013 20:21

wcwyes wrote:I did try the following and got the error <code>attempt to index global 'pt'(a nil value)</code>
Mossmanikin wrote:If you want to check for air, you could try replacing the line
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 pointed_thing.above = default:air then

with
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 minetest.get_node(pt.above).name=="air" then

(didn't test it)
furthermore I'd replace
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
else nil

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


Instead of pt, try pointed_thing as the variable. I think Mossmanikin shortened it.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Mon Sep 30, 2013 22:11

this got rid of the error but the tool still removes itself without placing a node if something is present there, i.e. the code ignores the check for air
wcwyes wrote:I did try the following and got the error <code>attempt to index global 'pt'(a nil value)</code>
Mossmanikin wrote:If you want to check for air, you could try replacing the line
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 pointed_thing.above = default:air then

with
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 minetest.get_node(pt.above).name=="air" then

(didn't test it)
furthermore I'd replace
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
else nil

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

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Mon Sep 30, 2013 23:38

If this is sort of what you are doing, why not just use the pointed_thing.above location so you don't have to do any math that would make it slightly slower.

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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    if pointed_thing.above = default:air then
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   else nil
end,


Plus, you need a comma after the right bracket } where you specify your special:myblock.

EDIT: Oops, sorry. I meant before the right bracket, just after the quotation mark.
Last edited by LionsDen on Mon Sep 30, 2013 23:41, edited 1 time in total.
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Mon Sep 30, 2013 23:42

if is not closed with end
also, "else nil" ? thats not even valid
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Tue Oct 01, 2013 00:41

I thought I saw that code somewhere, I'm new at lua so give me a break.
currently this is my code.
help rather than discriminatiion on my noob status in lua would be appreciated.
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_place = function(itemstack, placer, pointed_thing)
    if minetest.get_node(pointed_thing.above).name=="air" then
        local pt = pointed_thing
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   end
end,

RealBadAngel wrote:if is not closed with end
also, "else nil" ? thats not even valid
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Tue Oct 01, 2013 00:45

LionsDen wrote:If this is sort of what you are doing, why not just use the pointed_thing.above location so you don't have to do any math that would make it slightly slower.

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_place = function(itemstack, placer, pointed_thing)
    local pt = pointed_thing
    if pointed_thing.above = default:air then
        minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="special:myblock"})
        itemstack:take_item()
        return itemstack
   else nil
end,


Plus, you need a comma after the right bracket } where you specify your special:myblock.

EDIT: Oops, sorry. I meant before the right bracket, just after the quotation mark.

I'll try that. just taking suggestions and seeing what I can make of them right now. thanks.
EDIT:is there a way to get it to place like a normal node? My Server's owner doesn't seem to be very keen on a node placing different than nodes.
EDIT:just tried it and the tool completely disappears with out placing anything
Last edited by wcwyes on Tue Oct 01, 2013 19:05, edited 1 time in total.
 

User avatar
Mossmanikin
Member
 
Posts: 599
Joined: Sun May 19, 2013 16:26

by Mossmanikin » Tue Oct 01, 2013 22:19

wcwyes wrote:I'll try that. just taking suggestions and seeing what I can make of them right now. thanks.
EDIT:is there a way to get it to place like a normal node? My Server's owner doesn't seem to be very keen on a node placing different than nodes.
EDIT:just tried it and the tool completely disappears with out placing anything


A tested example:
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_node("tooltonodetest:mynode", {
    description = "My Node",
    tiles = {"default_stone.png^default_stick.png"},
})

minetest.register_tool("tooltonodetest:mytool", {
    description = "My Tool",
    inventory_image = "default_stick.png",
    on_place = function(itemstack, placer, pointed_thing)
        local pt = pointed_thing
        if minetest.get_node(pt.above).name=="air" then
            minetest.set_node(pt.above, {name="tooltonodetest:mynode"})
            itemstack:take_item()
            return itemstack
        end
    end,
})

Noob 4 life!
My stuff
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Wed Oct 02, 2013 00:17

Thanks for helping out works perfectly
Mossmanikin wrote:
wcwyes wrote:I'll try that. just taking suggestions and seeing what I can make of them right now. thanks.
EDIT:is there a way to get it to place like a normal node? My Server's owner doesn't seem to be very keen on a node placing different than nodes.
EDIT:just tried it and the tool completely disappears with out placing anything


A tested example:
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_node("tooltonodetest:mynode", {
    description = "My Node",
    tiles = {"default_stone.png^default_stick.png"},
})

minetest.register_tool("tooltonodetest:mytool", {
    description = "My Tool",
    inventory_image = "default_stick.png",
    on_place = function(itemstack, placer, pointed_thing)
        local pt = pointed_thing
        if minetest.get_node(pt.above).name=="air" then
            minetest.set_node(pt.above, {name="tooltonodetest:mynode"})
            itemstack:take_item()
            return itemstack
        end
    end,
})

Now back to the facedir issue I want the node to face the direction I'm facing when I use the tool.
Last edited by wcwyes on Wed Oct 02, 2013 00:44, edited 1 time in total.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Wed Oct 02, 2013 03:50

You can try this by replacing the line below with the line I am giving. This wont do the up and down direction, for that you need to use the newer facedir.

minetest.set_node(pt.above, {name="tooltonodetest:mynode"})

Here is the replacement line:

minetest.set_node(pt.above, {name="tooltonodetest:mynode", param2=minetest.dir_to_facedir(placer:get_look_dir())})

As long as your node allows the facedir to be set with param2 it should work or will be close. As far as I know, node and player facedirs use the same values but I'm not 100% sure on this.

EDIT: I forgot a d in an and word and missed a parenthesis.
Last edited by LionsDen on Wed Oct 02, 2013 03:54, edited 1 time in total.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Wed Oct 02, 2013 16:37

it's perfect now.
LionsDen wrote:You can try this by replacing the line below with the line I am giving. This wont do the up and down direction, for that you need to use the newer facedir.

minetest.set_node(pt.above, {name="tooltonodetest:mynode"})

Here is the replacement line:

minetest.set_node(pt.above, {name="tooltonodetest:mynode", param2=minetest.dir_to_facedir(placer:get_look_dir())})

As long as your node allows the facedir to be set with param2 it should work or will be close. As far as I know, node and player facedirs use the same values but I'm not 100% sure on this.

EDIT: I forgot a d in an and word and missed a parenthesis.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Wed Oct 02, 2013 21:24

That's great, glad we could help. :)
 

User avatar
Mossmanikin
Member
 
Posts: 599
Joined: Sun May 19, 2013 16:26

by Mossmanikin » Wed Oct 02, 2013 22:57

wcwyes wrote:it's perfect now.

LionsDen wrote:That's great, glad we could help. :)

Aye, me too. :)

Noob 4 life!
My stuff
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Thu Oct 31, 2013 18:22

 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

by BrunoMine » Thu Oct 31, 2013 21:10

there is a basic rule of naming functions to be registered?
songs and we for example.
My small square universe under construction ... Minemacro
Comunidade Minetest Brasil
www.minetestbrasil.com
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Fri Nov 01, 2013 16:54

I followed defaults example
brunob.santos wrote:there is a basic rule of naming functions to be registered?
songs and we for example.
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

by BrunoMine » Fri Nov 01, 2013 19:19

I'm learning.

Because I could not put the music on the node?
The music in this folder of the mod in "sounds".
Can you explain how?

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
-- mods/caixa/init.lua

minetest.register_node("caixa:caixa", {
    description = "Caixa",
    tiles = {"caixa_simples.png"},
    is_ground_content = true,
    groups = {cracky=3, stone=1},
    drop = 'caixa:caixa',
    legacy_mineral = true,
    sounds = musica_caixa.ogg,
})

My small square universe under construction ... Minemacro
Comunidade Minetest Brasil
www.minetestbrasil.com
 

PreviousNext

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 6 guests

cron