Making a tool do something on rightclick
Making a tool do something on rightclick
Is there an equivalent for on_use, but with rightclick instead of leftclick?
(ignore all posts on this topic from before today, that problem has been solved)
(ignore all posts on this topic from before today, that problem has been solved)
Last edited by qwrwed on Tue Dec 24, 2013 14:19, edited 1 time in total.
- webdesigner97
- Member
- Posts: 1328
- Joined: Mon Jul 30, 2012 19:16
- GitHub: webD97
- IRC: webdesigner97
- In-game: webdesigner97
- Location: Cologne, Germany
- Contact:
It seems to be his own indev mod.Krock wrote:I guess this should be posted into the mod's topic.
Visit me: webD97.de | @GitHub | @DeviantArt
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
I'm not sure this is the reason, but you forgot a parameter here:
Edit: same with the others in the same line.
Reference here.qwrwed wrote:if inv:get_stack('paxeltype') == paxeltype ...
Edit: same with the others in the same line.
Last edited by kaeza on Mon Dec 23, 2013 17:09, 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
Check out my stuff! | Donations greatly appreciated! PayPal
Thanks kaeza, the crash no longer happens, but the code still doesn't work:
What I am trying do do is: create a node with 5 slots in its formspec - material, pick, axe, shovel(inputs) and paxel(output). If the 4 input nodes are a complete set (e.g. ice crystal, ice pick, ice axe, and ice shovel) and the "Create Paxel" button is pressed, it removes everything from the input slots and places a paxel(e.g. ice paxel) in the output slot. However, on clicking the button, nothing happens.
Spoiler
Code: Select all
local paxelnodeformspec =
"size[8,9]"..
"label[3,0;Paxel Workshop]"..
"list[current_name;paxeltype;1,2;1,1;]"..
"label[0,2;Material:]"..
"list[current_name;pickaxe;3,1;1,1;]"..
"label[2,1;Pickaxe:]"..
"list[current_name;axe;3,2;1,1;]"..
"label[2,2; Axe:]"..
"list[current_name;shovel;3,3;1,1;]"..
"label[2,3; Shovel:]"..
"list[current_name;paxel;6,2;1,1;]"..
"label[5,2; Paxel:]"..
"list[current_player;main;0,5;8,4;]"..
"button[5,3;3,1;create;Create Paxel]"
local paxels = {
{'icetools:ice_crystal_refined', 'icetools:pick_ice', 'icetools:axe_ice', 'icetools:shovel_ice', 'icetools:paxel_ice'},
{'default:bucket_lava', 'magmatools:pick_magma', 'magmatools:axe_magma', 'magmatools:shovel_magma', 'magmatools:paxel_magma'},
--placeholder {'default:mese', 'default:pick_mese', 'default:axe_mese', 'default:shovel_mese', 'fire:basic_flame'}
}
for _, row in ipairs(paxels) do
local paxeltype = row[1]
local pick = row[2]
local axe = row[3]
local shovel = row[4]
local paxel = row[5]
minetest.register_node("icetools:paxelnode", {
description = "Paxel Workshop",
tiles = {"default_chest_top.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",paxelnodeformspec)
meta:set_string("infotext", "Paxel Workshop")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
inv:set_size("pickaxe", 1*1)
inv:set_size("axe", 1*1)
inv:set_size("shovel", 1*1)
inv:set_size("paxel", 1*1)
inv:set_size("paxeltype", 1*1)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname ~= "pickaxe" and listname ~= "axe" and listname ~= "shovel" and listname ~= "paxeltype" then
return 0
else
return 1
end
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if to_list == "paxel" then
return 0
else
return 1
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("pick") then
return false
elseif not inv:is_empty("axe") then
return false
elseif not inv:is_empty("shovel") then
return false
elseif not inv:is_empty("paxel") then
return false
end
return true
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
for k,v in pairs( fields ) do
if( k == 'create' ) then
if inv:get_stack('paxeltype', 1) == paxeltype --[[and inv:get_stack('pick', 1) == pick and inv:get_stack('axe', 1) == axe and inv:get_stack('shovel', 1) == shovel]] then
print("paxeltype is right")
inv:add_item("paxel", paxel)
inv:set_stack("pick", 1, nil)
inv:set_stack("axe", 1, nil)
inv:set_stack("shovel", 1, nil)
end
end
end
end,
groups = {choppy=3,oddly_breakable_by_hand=3},
})
end
Last edited by qwrwed on Mon Dec 23, 2013 19:47, edited 1 time in total.
- wtfsamcrap
- Member
- Posts: 25
- Joined: Mon Dec 09, 2013 21:23
- Location: Look behind you :)
- Contact:
Ehh heck if ik lua is not my strong spot c++ is but maby
Code: Select all
local tools ["",""]
function plrclick(player, rightclick)
if tools() then
local rightclick = player_rightclick()
if rightclick() then
<what you want it to do>
end
end
end
Mods
- Casimir
- Member
- Posts: 1206
- Joined: Fri Aug 03, 2012 16:59
- GitHub: CasimirKaPazi
Who is online
Users browsing this forum: No registered users and 13 guests