How do I make a node change when right-clicked with a bucket?

User avatar
scifiboi
Member
 
Posts: 96
Joined: Wed Jul 18, 2012 21:28

How do I make a node change when right-clicked with a bucket?

by scifiboi » Thu May 23, 2013 20:11

I've been trying to get a "cauldron" to change into a "cauldron_filled" by right-clicking it with a "bucket:bucket_water" in hand. I have tried several times and failed at each attempt. How would I go about this? Thanks in advanced.
This is a signature virus. Add me to your signature so that I can multiply.
My mod: Thaumtest
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Thu May 23, 2013 20:42

Use on_rightclick callback on the cauldron, and check the itemstack name.
EDIT: 1000th post!!!
Last edited by kaeza on Thu May 23, 2013 20:42, edited 1 time in total.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu May 23, 2013 21:35

kaeza wrote:EDIT: 1000th post!!!

Nice.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu May 23, 2013 21:51

PilzAdam wrote:
kaeza wrote:EDIT: 1000th post!!!

Nice.
Anyways, yeah, kaeza is right. Also: I'm 3.042x better.
Last edited by Jordach on Thu May 23, 2013 21:51, edited 1 time in total.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Thu May 23, 2013 22:20

kaeza wrote:Use on_rightclick callback on the cauldron, and check the itemstack name.
EDIT: 1000th post!!!

Exactly how do you check the itemstack name?
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Fri May 24, 2013 01:24

Evergreen wrote:Exactly how do you check the itemstack name?

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_rightclick = function(pos, node, clicker, itemstack)
  if itemstack:get_name() == "bucket:bucket_water" then
    -- Switch nodes here
  end
end
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri May 24, 2013 13:30

kaeza wrote:
Evergreen wrote:Exactly how do you check the itemstack name?

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_rightclick = function(pos, node, clicker, itemstack)
  if itemstack:get_name() == "bucket:bucket_water" then
    -- Switch nodes here
  end
end

Ah, thanks a lot. I wish someone would update the dev wiki so people(like me) wouldn't be asking questions like this.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri May 24, 2013 14:04

I am getting very close to getting this to work. Here is the 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
minetest.register_node("thaumtest:cauldron_empty",{
    drawtype="nodebox",
    description= "Cauldron",
    paramtype = "light",
    tiles = {"default_wood.png"},
    groups = {choppy=2},
    node_box = {
        type = "fixed",
        fixed = {
            {-0.500000,-0.375000,-0.500000,-0.375000,0.500000,0.500000},
            {0.375000,-0.375000,-0.500000,0.500000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,0.500000,-0.375000},
            {-0.500000,-0.375000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,-0.500000,-0.375000,0.500000,-0.375000},
            {0.375000,-0.500000,-0.500000,0.500000,0.500000,-0.375000},
            {0.375000,-0.500000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,0.375000,-0.375000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,-0.312500,0.500000},
        }
    }
    on_rightclick = function(pos, node, clicker, itemstack)
            if itemstack:get_name() == "bucket:bucket_water" then
               minetest.node_dig(pos, node, digger)
               minetest.env:remove_node(pos)
            end
    end,
   
    after_destruct = function(pos, oldnode)
        oldnode.name = "thaumtest:cauldron_full"
        minetest.env:set_node(pos, oldnode)
    end
})

Could you tell me what is wrong with it? I would appreciate it.
Last edited by Evergreen on Fri May 24, 2013 14:05, edited 1 time in total.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Fri May 24, 2013 20:06

why don't you call set_node(...) directly in on_rightclick?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri May 24, 2013 20:11

kaeza wrote:why don't you call set_node(...) directly in on_rightclick?

Okay, thanks.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri May 24, 2013 20:22

I still get an error though. Here is the 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
minetest.register_node("thaumtest:cauldron_empty",{
    drawtype="nodebox",
    description= "Cauldron",
    paramtype = "light",
    tiles = {"default_wood.png"},
    groups = {choppy=2},
    node_box = {
        type = "fixed",
        fixed = {
            {-0.500000,-0.375000,-0.500000,-0.375000,0.500000,0.500000},
            {0.375000,-0.375000,-0.500000,0.500000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,0.500000,-0.375000},
            {-0.500000,-0.375000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,-0.500000,-0.375000,0.500000,-0.375000},
            {0.375000,-0.500000,-0.500000,0.500000,0.500000,-0.375000},
            {0.375000,-0.500000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,0.375000,-0.375000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,-0.312500,0.500000},
        }
    }
    on_rightclick = function(pos, node, clicker, itemstack)
            if itemstack:get_name() == "bucket:bucket_water" then
                  minetest.env:set_node(pos, "thaumtest:cauldron_full")
            end
    end
    }
})
Last edited by Evergreen on Fri May 24, 2013 21:03, edited 1 time in total.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
doyousketch2
Member
 
Posts: 82
Joined: Tue Feb 05, 2013 16:06
GitHub: doyousketch2
In-game: Sketch2

by doyousketch2 » Wed May 29, 2013 21:49

I think in your last line you have one too many closing brackets.

Take out the squiggly }
Just leave the )

I also think you need commas after the closing brackets that you do have.

There's 3 of these }

That should look like this instead:

},

not tested, but this looks more correct to me:

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("thaumtest:cauldron_empty",{
    drawtype="nodebox",
    description= "Cauldron",
    paramtype = "light",
    tiles = {"default_wood.png"},
    groups = {choppy=2},
    node_box = {
        type = "fixed",
        fixed = {
            {-0.500000,-0.375000,-0.500000,-0.375000,0.500000,0.500000},
            {0.375000,-0.375000,-0.500000,0.500000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,0.500000,-0.375000},
            {-0.500000,-0.375000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,-0.500000,-0.375000,0.500000,-0.375000},
            {0.375000,-0.500000,-0.500000,0.500000,0.500000,-0.375000},
            {0.375000,-0.500000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,0.375000,-0.375000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,-0.312500,0.500000},
        },
    },
    on_rightclick = function(pos, node, clicker, itemstack)
            if itemstack:get_name() == "bucket:bucket_water" then
                  minetest.env:set_node(pos, "thaumtest:cauldron_full")
            end
    end
    },
)
Last edited by doyousketch2 on Wed May 29, 2013 21:54, edited 1 time in total.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Wed May 29, 2013 22:02

doyousketch2 wrote:I think in your last line you have one too many closing brackets.

Take out the squiggly }
Just leave the )

I also think you need commas after the closing brackets that you do have.

There's 3 of these }

That should look like this instead:

},

not tested, but this looks more correct to me:

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("thaumtest:cauldron_empty",{
    drawtype="nodebox",
    description= "Cauldron",
    paramtype = "light",
    tiles = {"default_wood.png"},
    groups = {choppy=2},
    node_box = {
        type = "fixed",
        fixed = {
            {-0.500000,-0.375000,-0.500000,-0.375000,0.500000,0.500000},
            {0.375000,-0.375000,-0.500000,0.500000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,0.500000,-0.375000},
            {-0.500000,-0.375000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,-0.500000,-0.375000,0.500000,-0.375000},
            {0.375000,-0.500000,-0.500000,0.500000,0.500000,-0.375000},
            {0.375000,-0.500000,0.375000,0.500000,0.500000,0.500000},
            {-0.500000,-0.500000,0.375000,-0.375000,0.500000,0.500000},
            {-0.500000,-0.375000,-0.500000,0.500000,-0.312500,0.500000},
        },
    },
    on_rightclick = function(pos, node, clicker, itemstack)
            if itemstack:get_name() == "bucket:bucket_water" then
                  minetest.env:set_node(pos, "thaumtest:cauldron_full")
            end
    end
    },
)

No, it is working, but I had a problem that I posted in the modding questions topic.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 7 guests

cron