123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- 2,11c2
- < local color = '#FF6700'
- < local TechnicMaxCharge = 300000
- < chisel = {}
- <
- < chisel.materials = {}
- < chisel.mods = {}
- < chisel.selected = {}
- < chisel.active = {}
- < chisel.program = {}
- < chisel.mode = {}
- ---
- > local mode = {}
- 12a4,12
- > local function parti(pos)
- > minetest.add_particlespawner(25, 0.3,
- > pos, pos,
- > {x=2, y=0.2, z=2}, {x=-2, y=2, z=-2},
- > {x=0, y=-6, z=0}, {x=0, y=-10, z=0},
- > 0.2, 1,
- > 0.2, 2,
- > true, "mychisel_parti.png")
- > end
- 13a14
- > mode = "1"
- 14a16,19
- > minetest.register_tool( "mychisel:chisel",{
- > description = "Chisel",
- > inventory_image = "mychisel_chisel.png",
- > wield_image = "mychisel_chisel.png",
- 16c21
- < local wehavetechnic = minetest.get_modpath("technic")
- ---
- > on_use = function(itemstack, user, pointed_thing)
- 17a23,25
- > if pointed_thing.type ~= "node" then
- > return
- > end
- 19,20c27,28
- <
- <
- ---
- > local pos = pointed_thing.under
- > local node = minetest.get_node(pos)
- 22c30
- < local default_material = {
- ---
- > local default_material = {
- 40,185d47
- < -- Chatcommand to show loaded mods with names and number of styles
- <
- < minetest.register_chatcommand("chisel", {
- < params = "",
- < description = "Shows supported mods in mychisel",
- < privs = {interact = true},
- < func = function(name, poi_name)
- <
- < for i in ipairs (chisel.mods) do
- <
- < minetest.chat_send_player(name,core.colorize(color,i..") modname :"..chisel.mods[i][1].." styles: "..chisel.mods[i][2]))
- < end
- <
- < end,
- < })
- <
- < -- global API
- <
- < function chisel.register_node(modname, prefix, raw, design) -- global function to register new stuff
- < local counter = chisel.count_stuff() +1
- < chisel.materials [counter] = {}
- < chisel.materials [counter][1] = modname
- < chisel.materials [counter][2] = prefix
- < chisel.materials [counter][3] = raw
- < chisel.materials [counter][4] = design
- < end
- <
- <
- < function chisel.add_mod(modname,number) -- global function to init a new mod for the chisel.
- < local counter = chisel.count_mods() +1
- < chisel.mods [counter] = {}
- < chisel.mods [counter][1] = modname
- < chisel.mods [counter][2] = number
- < minetest.log("action","[CHISEL] Added mod "..modname .. " with " .. number.." styles to mychisel") -- log loaded mods to debug.txt
- < end
- <
- <
- <
- < function chisel.count_stuff() -- how many materials have been registered already ?
- < local counter = 0
- < for i in ipairs (chisel.materials) do counter = counter +1 end
- < return counter
- < end
- <
- <
- <
- < function chisel.count_mods() -- how many different mods are registered ?
- <
- < local counter = 0
- < for i in ipairs (chisel.mods) do counter = counter +1 end
- < return counter
- < end
- <
- <
- <
- <
- < -- init chisel for each player joining
- <
- < local function chiselinit(name)
- < chisel.selected[name] = 1
- < chisel.active[name] = "default"
- < chisel.program[name] = 1
- < chisel.mode[name] = "1"
- < end
- <
- < minetest.register_on_joinplayer(function(player)
- < chiselinit(player:get_player_name())
- < end)
- <
- < -- end init
- <
- <
- <
- <
- < local function parti(pos)
- < minetest.add_particlespawner(25, 0.3,
- < pos, pos,
- < {x=2, y=0.2, z=2}, {x=-2, y=2, z=-2},
- < {x=0, y=-6, z=0}, {x=0, y=-10, z=0},
- < 0.2, 1,
- < 0.2, 2,
- < true, "mychisel_parti.png")
- < end
- <
- <
- <
- <
- < local function chiselcut(pos,user,node)
- < local name = user:get_player_name()
- <
- < for i in ipairs (chisel.materials) do
- <
- < if chisel.materials[i][1] == chisel.active[name] then
- < if node.name == chisel.materials[i][3] and chisel.materials[i][4] == chisel.materials[chisel.program[name]][4] then
- <
- < minetest.set_node(pos, {name=chisel.materials[i][1]..":"..chisel.materials[i][2].."_"..chisel.materials[i][4], param2=minetest.dir_to_facedir(user:get_look_dir())})
- < end
- < end
- < end
- < end
- <
- <
- < local function change_mode(user, choice)
- <
- < local name = user:get_player_name()
- <
- <
- < if choice then
- < if chisel.mode[name] == "1" then
- < chisel.mode[name] = "2"
- < minetest.chat_send_player(name,core.colorize(color, "Horizontal Groove"))
- <
- < elseif chisel.mode[name] == "2" then
- < chisel.mode[name] = "3"
- < minetest.chat_send_player(name,core.colorize(color, "Vertical Groove"))
- <
- < elseif chisel.mode[name] == "3" then
- < chisel.mode[name] = "4"
- < minetest.chat_send_player(name, core.colorize(color, "Cross Grooves"))
- <
- < elseif chisel.mode[name] == "4" then
- < chisel.mode[name] = "5"
- < minetest.chat_send_player(name, core.colorize(color, "Square"))
- <
- < elseif chisel.mode[name] == "5" then
- < chisel.mode[name] = "1"
- < minetest.chat_send_player(name, core.colorize(color, "Chisel 4 Edges"))
- < end
- < else
- < chisel.program[name] = chisel.program[name] +1
- < if chisel.program[name] > chisel.mods [chisel.selected[name]][2] then chisel.program[name] = 1 end
- < minetest.chat_send_player(name, core.colorize(color, chisel.materials [chisel.program[name]][4]))
- < end
- <
- < end
- <
- <
- <
- <
- < local function chiselme(pos, user, node)
- <
- <
- < local name = user:get_player_name()
- <
- <
- <
- 190d51
- <
- 192c53,62
- < if chisel.mode[name] == "1" then
- ---
- > if pointed_thing.type ~= "node" then
- > return
- > end
- >
- > if minetest.is_protected(pos, user:get_player_name()) then
- > minetest.record_protection_violation(pos, user:get_player_name())
- > return
- > end
- >
- > if mode == "1" then
- 197d66
- <
- 203d71
- <
- 209d76
- <
- 215d81
- <
- 217,218d82
- <
- <
- 221c85
- < if chisel.mode[name] == "2" then
- ---
- > if mode == "2" then
- 226d89
- <
- 232d94
- <
- 238d99
- <
- 244d104
- <
- 246d105
- <
- 249c108
- < if chisel.mode[name] == "3" then
- ---
- > if mode == "3" then
- 254d112
- <
- 260d117
- <
- 266d122
- <
- 272d127
- <
- 274d128
- <
- 277c131
- < if chisel.mode[name] == "4" then
- ---
- > if mode == "4" then
- 282d135
- <
- 288d140
- <
- 294d145
- <
- 300d150
- <
- 302d151
- <
- 305c154
- < if chisel.mode[name] == "5" then
- ---
- > if mode == "5" then
- 310d158
- <
- 316d163
- <
- 322d168
- <
- 328d173
- <
- 330d174
- <
- 332a177,192
- > if mode == "6" then
- > -- on_place = function(itemstack, placer, pointed_thing)
- > local pt = pointed_thing
- > if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
- > local wear = itemstack:get_wear()
- > local direction = minetest.dir_to_facedir(user:get_look_dir())
- > local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
- > local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
- > minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="mychisel:chisel_deco", param2=direction})
- > meta1:set_int("wear", wear)
- > meta2:set_int("wear", wear)
- > itemstack:take_item()
- > return itemstack
- > end
- > end
- >
- 334,335d193
- <
- < end
- 337,338c195,197
- <
- < if not wehavetechnic then
- ---
- > if not minetest.setting_getbool("creative_mode") then
- > itemstack:add_wear(65535 / (USES - 1))
- > end
- 340,531c199,221
- < minetest.register_tool( "mychisel:chisel",{
- < description = "Chisel",
- < inventory_image = "mychisel_chisel.png",
- < wield_image = "mychisel_chisel.png",
- <
- < on_use = function(itemstack, user, pointed_thing)
- <
- < if pointed_thing.type ~= "node" then
- < return
- < end
- <
- < local pos = pointed_thing.under
- < local node = minetest.get_node(pos)local feedback = false
- < local name = user:get_player_name()
- <
- <
- <
- <
- < if minetest.is_protected(pos, user:get_player_name()) then
- < minetest.record_protection_violation(pos, user:get_player_name())
- < return
- < end
- <
- <
- < if chisel.active[name] == "default" then
- < chiselme(pos,user,node)
- <
- < else
- <
- < chiselcut(pos,user,node)
- <
- < end
- <
- <
- < if not minetest.setting_getbool("creative_mode") then
- < itemstack:add_wear(65535 / (USES - 1))
- < end
- <
- < return itemstack
- <
- < end,
- <
- < on_place = function(itemstack, user, pointed_thing)
- <
- <
- < local number = chisel.count_mods()
- < local keys = user:get_player_control()
- < local name = user:get_player_name()
- <
- <
- <
- < -- change design mode of chisel by pressing sneak while right-clicking
- < if( not( keys["sneak"] )) then
- < if chisel.active[name] == "default" then
- < change_mode(user,true)
- < else
- <
- < change_mode(user,false)
- <
- < end
- < else
- < chisel.selected[name] = chisel.selected[name] +1
- < if chisel.selected[name] > chisel.count_mods() then chisel.selected[name] = 1 end
- <
- < chisel.active[name] = chisel.mods[chisel.selected[name]][1]
- < minetest.chat_send_player(user:get_player_name(), core.colorize(color, " ***>>> switched to mod: "..chisel.active[name]))
- <
- < end
- <
- < return itemstack
- <
- < end
- <
- < })
- <
- < minetest.register_craft({
- < output = "mychisel:chisel",
- < recipe = {
- < {"default:steel_ingot"},
- < {"wool:brown"},
- < },
- < })
- <
- <
- <
- <
- < else
- <
- <
- < local S = technic.getter
- <
- < technic.register_power_tool("mychisel:chisel",TechnicMaxCharge)
- < local chisel_charge_per_node =math.floor( TechnicMaxCharge / USES )
- <
- <
- < minetest.register_tool("mychisel:chisel", {
- < description = S("Chisel"),
- < inventory_image = "mychisel_chisel.png",
- < stack_max = 1,
- < wear_represents = "technic_RE_charge",
- < on_refill = technic.refill_RE_charge,
- < on_use = function(itemstack, user, pointed_thing)
- <
- <
- < if pointed_thing.type ~= "node" then
- < return
- < end
- <
- < local pos = pointed_thing.under
- < local node = minetest.get_node(pos)
- < local name = user:get_player_name()
- <
- <
- <
- < if minetest.is_protected(pos, user:get_player_name()) then
- < minetest.record_protection_violation(pos, user:get_player_name())
- < return
- < end
- <
- < --
- <
- < local meta = minetest.deserialize(itemstack:get_metadata())
- < if not meta or not meta.charge or
- < meta.charge < chisel_charge_per_node then
- < return
- < end
- <
- < if chisel.active[name] == "default" then
- < chiselme(pos,user,node)
- < meta.charge = meta.charge - chisel_charge_per_node
- < else
- <
- < chiselcut(pos,user,node)
- < meta.charge = meta.charge - chisel_charge_per_node
- < end
- <
- <
- <
- < if not technic.creative_mode then
- < technic.set_RE_wear(itemstack, meta.charge, TechnicMaxCharge)
- < itemstack:set_metadata(minetest.serialize(meta))
- < end
- <
- < return itemstack
- <
- <
- < end,
- <
- < on_place = function(itemstack, user, pointed_thing)
- <
- < local number = chisel.count_mods()
- < local keys = user:get_player_control()
- < local name = user:get_player_name()
- <
- <
- <
- < -- change design mode of chisel by pressing sneak while right-clicking
- < if( not( keys["sneak"] )) then
- < if chisel.active[name] == "default" then
- < change_mode(user,true)
- < else
- <
- < change_mode(user,false)
- <
- < end
- < else
- < chisel.selected[name] = chisel.selected[name] +1
- < if chisel.selected[name] > chisel.count_mods() then chisel.selected[name] = 1 end
- <
- < chisel.active[name] = chisel.mods[chisel.selected[name]][1]
- < minetest.chat_send_player(user:get_player_name(),core.colorize(color, " ***>>> switched to mod: "..chisel.active[name]))
- <
- < end
- <
- < return itemstack
- <
- < end
- < })
- <
- <
- < minetest.register_craft({
- < output = "mychisel:chisel",
- < recipe = {
- < {"default:diamond", "default:diamond" , "default:diamond" },
- < {"", "technic:stainless_steel_ingot", ""},
- < {"", "technic:battery", ""},
- < }
- < })
- <
- <
- <
- < end
- ---
- > return itemstack
- >
- > end,
- >
- > on_place = function(itemstack, user, pointed_thing)
- >
- > local usr = user:get_player_name()
- >
- > if mode == "1" then
- > mode = "2"
- > minetest.chat_send_player(usr,"Horizontal Groove")
- >
- > elseif mode == "2" then
- > mode = "3"
- > minetest.chat_send_player(usr,"Vertical Groove")
- >
- > elseif mode == "3" then
- > mode = "4"
- > minetest.chat_send_player(usr,"Cross Grooves")
- >
- > elseif mode == "4" then
- > mode = "5"
- > minetest.chat_send_player(usr,"Square")
- 533c223,247
- < chisel.add_mod("default",5)
- \ No newline at end of file
- ---
- > elseif mode == "5" then
- > mode = "6"
- > minetest.chat_send_player(usr,"Place Tool")
- > elseif mode == "6" then
- > mode = "1"
- > minetest.chat_send_player(usr,"Chisel 4 Edges")
- > end
- >
- > if not minetest.setting_getbool("creative_mode") then
- > itemstack:add_wear(65535 / (USES - 1))
- > end
- >
- > return itemstack
- >
- > end
- >
- > })
- >
- > minetest.register_craft({
- > output = "mychisel:chisel",
- > recipe = {
- > {"default:steel_ingot"},
- > {"wool:brown"},
- > },
- > })
|