commit | author | age
|
ee0765
|
1 |
local sonic_screwdriver_max_charge = 15000 |
S |
2 |
technic.register_power_tool("technic:sonic_screwdriver", sonic_screwdriver_max_charge) |
e23f87
|
3 |
|
R |
4 |
minetest.register_tool("technic:sonic_screwdriver", { |
|
5 |
description = "Sonic Screwdriver", |
|
6 |
inventory_image = "technic_sonic_screwdriver.png", |
|
7 |
on_use = function(itemstack, user, pointed_thing) |
|
8 |
-- Must be pointing to facedir applicable node |
|
9 |
if pointed_thing.type~="node" then return end |
|
10 |
local pos=minetest.get_pointed_thing_position(pointed_thing,above) |
|
11 |
local node=minetest.env:get_node(pos) |
|
12 |
local node_name=node.name |
|
13 |
if minetest.registered_nodes[node_name].paramtype2 == "facedir" or minetest.registered_nodes[node_name].paramtype2 == "wallmounted" then |
|
14 |
if node.param2==nil then return end |
|
15 |
item=itemstack:to_table() |
|
16 |
local meta1=get_item_meta(item["metadata"]) |
8f485a
|
17 |
if meta1==nil then return end --tool not charghed |
R |
18 |
if meta1["charge"]==nil then return end |
e23f87
|
19 |
charge=meta1["charge"] |
R |
20 |
if charge-100>0 then |
|
21 |
minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 0.3, max_hear_distance = 10,}) |
|
22 |
local n = node.param2 |
|
23 |
if minetest.registered_nodes[node_name].paramtype2 == "facedir" then |
|
24 |
n = n+1 |
|
25 |
if n == 4 then n = 0 end |
|
26 |
else |
|
27 |
n = n+1 |
|
28 |
if n == 6 then n = 0 end |
|
29 |
end |
|
30 |
-- hacky_swap_node, unforunatly. |
|
31 |
local meta = minetest.env:get_meta(pos) |
|
32 |
local meta0 = meta:to_table() |
|
33 |
node.param2 = n |
|
34 |
minetest.env:set_node(pos,node) |
|
35 |
meta = minetest.env:get_meta(pos) |
|
36 |
meta:from_table(meta0) |
|
37 |
|
|
38 |
charge=charge-100; |
|
39 |
meta1["charge"]=charge |
|
40 |
item["metadata"]=set_item_meta(meta1) |
6e4ffb
|
41 |
technic.set_RE_wear(item,charge,sonic_screwdriver_max_charge) |
e23f87
|
42 |
itemstack:replace(item) |
R |
43 |
end |
|
44 |
return itemstack |
|
45 |
else |
|
46 |
return itemstack |
|
47 |
end |
|
48 |
end, |
|
49 |
|
|
50 |
}) |
|
51 |
|
|
52 |
minetest.register_craft({ |
|
53 |
output = "technic:sonic_screwdriver", |
|
54 |
recipe = { |
cdb368
|
55 |
{"default:diamond"}, |
e23f87
|
56 |
{"technic:battery"}, |
R |
57 |
{"technic:stainless_steel_ingot"} |
|
58 |
} |
|
59 |
}) |