diff --git a/.luacheckrc b/.luacheckrc index b58f51f..c552fde 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -2,7 +2,7 @@ unused_args = false max_line_length = false globals = { - "minetest", "cannons" + "core", "cannons" } read_globals = { diff --git a/bower.json b/bower.json index 175c6b4..cfa579b 100644 --- a/bower.json +++ b/bower.json @@ -1,13 +1,13 @@ { "name": "cannons", - "description": "To shoot insert muni and gunpowder and punch the cannon with a torch.", + "description": "To shoot, insert munitions and gunpowder and punch the cannon with a torch.", "keywords": [ "cannon", "cannons", "medieval", "shoot" ], - "forum": "http://forum.minetest.net/viewtopic.php?f=11&t=7744", + "forum": "http://forum.luanti.org/viewtopic.php?f=11&t=7744", "screenshots": [ "https://bitbucket.org/kingarthursteam/cannons/raw/master/screenshot.png", "https://bitbucket.org/kingarthursteam/cannons/wiki/screenshots/screenshot_1531516.png", diff --git a/cannonballs.lua b/cannonballs.lua index f5c456c..e9ec334 100644 --- a/cannonballs.lua +++ b/cannonballs.lua @@ -30,7 +30,7 @@ local exploding={ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) cannons.destroy({x=pos.x, y=pos.y, z=pos.z},self.range) - minetest.sound_play("cannons_shot", + core.sound_play("cannons_shot", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end, @@ -64,8 +64,8 @@ local fire={ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) pos = self.lastpos - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="fire:basic_flame"}) - minetest.sound_play("default_break_glass", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="fire:basic_flame"}) + core.sound_play("default_break_glass", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end, @@ -96,7 +96,7 @@ cannons.register_muni("cannons:ball_wood_stack_1",{ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_all(playername .." tried to catch a cannonball") + core.chat_send_all(playername .." tried to catch a cannonball") end, on_mob_hit = function(self,pos,mob) mob:punch(self.object, 1.0, { @@ -108,16 +108,16 @@ cannons.register_muni("cannons:ball_wood_stack_1",{ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) if node.name == "default:dirt_with_grass" then - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) - minetest.sound_play("cannons_hit", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() elseif node.name == "default:water_source" then - minetest.sound_play("cannons_splash", + core.sound_play("cannons_splash", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() else - minetest.sound_play("cannons_hit", + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end @@ -146,7 +146,7 @@ cannons.register_muni("cannons:ball_stone_stack_1",{ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_all(playername .." tried to catch a cannonball") + core.chat_send_all(playername .." tried to catch a cannonball") end, on_mob_hit = function(self,pos,mob) mob:punch(self.object, 1.0, { @@ -158,16 +158,16 @@ cannons.register_muni("cannons:ball_stone_stack_1",{ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) if node.name == "default:dirt_with_grass" then - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) - minetest.sound_play("cannons_hit", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() elseif node.name == "default:water_source" then - minetest.sound_play("cannons_splash", + core.sound_play("cannons_splash", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() else - minetest.sound_play("cannons_hit", + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end @@ -196,7 +196,7 @@ cannons.register_muni("cannons:ball_steel_stack_1",{ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_all(playername .." tried to catch a canonball") + core.chat_send_all(playername .." tried to catch a canonball") end, on_mob_hit = function(self,pos,mob) mob:punch(self.object, 1.0, { @@ -208,16 +208,16 @@ cannons.register_muni("cannons:ball_steel_stack_1",{ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) if node.name == "default:dirt_with_grass" then - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) - minetest.sound_play("cannons_hit", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() elseif node.name == "default:water_source" then - minetest.sound_play("cannons_splash", + core.sound_play("cannons_splash", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() else - minetest.sound_play("cannons_hit", + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end diff --git a/convert.lua b/convert.lua index 93efe4d..9360a18 100644 --- a/convert.lua +++ b/convert.lua @@ -1,16 +1,16 @@ -minetest.register_abm({ +core.register_abm({ nodenames = {"cannons:cannon","cannons:bronze_canon","cannons:mithril_cannon"}, --neighbors = {"cannons:stand","cannons.stand_wood"}, interval = 1.0, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local stand_pos = {x= pos.x,y= pos.y-1,z=pos.z} - local stand = minetest.get_node(stand_pos) + local stand = core.get_node(stand_pos) if stand.name == "cannons:stand" or stand.name == "cannons:stand_wood" then -- cannon stand with cannon if stand.name == "cannons:stand" then - minetest.set_node(stand_pos, {name = "default:cobble"})--replace stand with cobblestone + core.set_node(stand_pos, {name = "default:cobble"})--replace stand with cobblestone else - minetest.set_node(stand_pos, {name = "default:wood"})--replace stand with cobblestone + core.set_node(stand_pos, {name = "default:wood"})--replace stand with cobblestone end if node.name == "cannons:cannon" then node.name = "cannons:wood_stand_with_cannon_steel" @@ -24,7 +24,7 @@ minetest.register_abm({ node.name = "air" end - minetest.swap_node(pos, node) + core.swap_node(pos, node) else --else its a single or disabled cannon print("zweite if") @@ -39,28 +39,28 @@ minetest.register_abm({ else --dont know what else can happen, but "Der Teufel ist ein Eichh�rnchen" node.name = "air" end - minetest.swap_node(pos, node) + core.swap_node(pos, node) end end, }) --abm to convert single cannonstands -minetest.register_abm({ +core.register_abm({ nodenames = {"cannons:stand","cannons:stand_wood"}, interval = 1.0, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local above_pos = {x= pos.x,y= pos.y+1,z=pos.z} - local above = minetest.get_node(above_pos) + local above = core.get_node(above_pos) --if above the stand a cannon... if above.name == "air" then - minetest.set_node(above_pos, {name = "cannons:wood_stand"}) + core.set_node(above_pos, {name = "cannons:wood_stand"}) else --replace single stands with a full block, and place the stand above it if node.name == "cannons:stand" then - minetest.set_node(pos, {name = "default:cobble"})--replace stand with cobblestone + core.set_node(pos, {name = "default:cobble"})--replace stand with cobblestone else - minetest.set_node(pos, {name = "default:wood"})--replace stand with cobblestone + core.set_node(pos, {name = "default:wood"})--replace stand with cobblestone end end end, diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 77355e3..0000000 --- a/depends.txt +++ /dev/null @@ -1,6 +0,0 @@ -default -bucket -mesecons? -locks? -moreores? -tnt? diff --git a/description.txt b/description.txt deleted file mode 100644 index d24a201..0000000 --- a/description.txt +++ /dev/null @@ -1,3 +0,0 @@ -The Cannons mod adds Cannons to the game. -to shot insert muni and gunpowder and punch that with a torch. -the muni can destroy nodes and hurts players. \ No newline at end of file diff --git a/functions.lua b/functions.lua index bc05f91..2bce155 100644 --- a/functions.lua +++ b/functions.lua @@ -6,13 +6,13 @@ function cannons.destroy(pos,range) if x*x+y*y+z*z <= range * range + range then local np={x=pos.x+x,y=pos.y+y,z=pos.z+z} - if minetest.is_protected(np, "") then + if core.is_protected(np, "") then return -- fail fast end - local n = minetest.env:get_node(np) + local n = core.env:get_node(np) if n.name ~= "air" then - minetest.env:remove_node(np) + core.env:remove_node(np) end end end @@ -33,7 +33,7 @@ function cannons.sound_defaults(table) return table end function cannons.inventory_modified(pos) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local inv = meta:get_inventory() local muni = inv:get_stack("muni", 1):to_table() local gunpowder = inv:get_stack("gunpowder", 1):to_table(); @@ -65,7 +65,7 @@ end cannons.allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) if(meta:get_string("owner") ~="" and not(locks:lock_allow_use( pos, player ))) then return 0; end @@ -80,7 +80,7 @@ cannons.allow_metadata_inventory_put = function(pos, listname, index, stack, pla cannons.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) if(meta:get_string("owner") ~="" and not( locks:lock_allow_use( pos, player ))) then return 0; end @@ -98,7 +98,7 @@ cannons.allow_metadata_inventory_move = function(pos, from_list, from_index, to_ end cannons.can_dig = function(pos,player) - local meta = minetest.get_meta(pos); + local meta = core.get_meta(pos); local inv = meta:get_inventory() if not inv:is_empty("gunpowder") then return false @@ -144,28 +144,28 @@ if default and default.gui_slots then end cannons.on_construct = function(pos) - local node = minetest.get_node({x = pos.x ,y = pos.y, z = pos.z}) - if minetest.registered_items[node.name].cannons then - local meta = minetest.get_meta(pos) + local node = core.get_node({x = pos.x ,y = pos.y, z = pos.z}) + if core.registered_items[node.name].cannons then + local meta = core.get_meta(pos) meta:set_string("formspec", cannons.formspec) meta:set_string("infotext", "Cannon has no muni and no gunpowder") local inv = meta:get_inventory() inv:set_size("gunpowder", 1) inv:set_size("muni", 1) else - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) meta:set_string("formspec", cannons.disabled_formspec) meta:set_string("infotext", "Cannon is out of order") end end cannons.stand_on_rightclick = function(pos, node, player, itemstack, pointed_thing) - if minetest.get_item_group(itemstack:get_name(), "cannon")>=1 then --if rightclicked with a cannon + if core.get_item_group(itemstack:get_name(), "cannon")>=1 then --if rightclicked with a cannon local item = string.split(itemstack:get_name(),":")[2]; node.name=node.name.."_with_"..item ---print(node.name); - minetest.swap_node(pos, node) - local meta = minetest.get_meta(pos) + core.swap_node(pos, node) + local meta = core.get_meta(pos) meta:set_string("formspec", cannons.formspec) meta:set_string("infotext", "Cannon has no muni and no gunpowder") local inv = meta:get_inventory() @@ -183,23 +183,23 @@ cannons.dug = function(pos, node, digger) if not digger or not digger:is_player() then return end - local cannons = minetest.registered_nodes[node.name].cannons + local cannons = core.registered_nodes[node.name].cannons if cannons and cannons.stand and cannons.cannon then --node dug node.name = cannons.stand - minetest.swap_node(pos, node)--replace node with the stand - local meta = minetest.get_meta(pos) + core.swap_node(pos, node)--replace node with the stand + local meta = core.get_meta(pos) meta:set_string("formspec","") meta:set_string("infotext", "place a cannon on this stand") local inv = digger:get_inventory() local stack = inv:add_item("main", ItemStack(cannons.cannon))--add the cannon to the ineentory - minetest.item_drop(stack, digger, pos) + core.item_drop(stack, digger, pos) end end cannons.on_construct_locks = function(pos) - local node = minetest.get_node({x = pos.x ,y = pos.y-1, z = pos.z}) - if minetest.registered_nodes[node.name].groups.cannonstand then - local meta = minetest.get_meta(pos) + local node = core.get_node({x = pos.x ,y = pos.y-1, z = pos.z}) + if core.registered_nodes[node.name].groups.cannonstand then + local meta = core.get_meta(pos) meta:set_string("formspec", cannons.formspec.. "field[2,1.3;6,0.7;locks_sent_lock_command;Locked Cannon. Type /help for help:;]".. "button[6,2;1.7,0.7;locks_sent_input;Proceed]") @@ -208,16 +208,16 @@ cannons.on_construct_locks = function(pos) inv:set_size("gunpowder", 1) inv:set_size("muni", 1) else - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) meta:set_string("formspec", cannons.disabled_formspec) meta:set_string("infotext", "Cannon is out of order") end end function cannons.nodehitparticles(pos,node) -if type(minetest.registered_nodes[node.name]) == "table" and type(minetest.registered_nodes[node.name].tiles) == "table" and type(minetest.registered_nodes[node.name].tiles[1])== "string" then - local texture = minetest.registered_nodes[node.name].tiles[1] - minetest.add_particlespawner( +if type(core.registered_nodes[node.name]) == "table" and type(core.registered_nodes[node.name].tiles) == "table" and type(core.registered_nodes[node.name].tiles[1])== "string" then + local texture = core.registered_nodes[node.name].tiles[1] + core.add_particlespawner( 30, --amount 0.5, --time {x=pos.x-0.3, y=pos.y+0.3, z=pos.z-0.3}, --minpos @@ -236,7 +236,7 @@ if type(minetest.registered_nodes[node.name]) == "table" and type(minetest.regis end end function cannons.fire(pos,node,puncher) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local inv = meta:get_inventory() local muni = inv:get_stack("muni", 1):to_table(); local gunpowder = inv:get_stack("gunpowder", 1):to_table(); @@ -252,14 +252,14 @@ function cannons.fire(pos,node,puncher) then if puncher ~= nil then dir=puncher:get_look_dir() - meta:set_string("dir", minetest.serialize(dir)) + meta:set_string("dir", core.serialize(dir)) else - dir = minetest.deserialize(meta:get_string("dir")); + dir = core.deserialize(meta:get_string("dir")); if dir == nil then return end end - minetest.sound_play("cannons_shot", + core.sound_play("cannons_shot", {pos = pos, gain = 1.0, max_hear_distance = 32,}) @@ -269,10 +269,10 @@ function cannons.fire(pos,node,puncher) local settings = cannons.get_settings(muni.name) - local obj=minetest.env:add_entity(pos, cannons.get_entity(muni.name)) + local obj=core.env:add_entity(pos, cannons.get_entity(muni.name)) obj:setvelocity({x=dir.x*settings.velocity, y=-1, z=dir.z*settings.velocity}) obj:setacceleration({x=dir.x*-3, y=-settings.gravity, z=dir.z*-3}) - minetest.add_particlespawner(50,0.5, + core.add_particlespawner(50,0.5, pos, pos, {x=dir.x*settings.velocity, y=-1, z=dir.z*settings.velocity}, {x=dir.x*settings.velocity/2, y=-1, z=dir.z*settings.velocity/2}, {x=dir.x*-3/4, y=-settings.gravity*2, z=dir.z*-3/4}, {x=dir.x*-3/2, y=-settings.gravity, z=dir.z*-3/2}, @@ -311,10 +311,10 @@ function cannons.register_muni(node,entity) self.timer=self.timer+dtime if self.timer >= 0.3 then --easiesst less laggiest way to find out that it left his start position local pos = self.object:getpos() - node = minetest.env:get_node(pos) + node = core.env:get_node(pos) if node.name == "air" then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, self.range) + local objs = core.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, self.range) for k, obj in pairs(objs) do if obj:get_luaentity() ~= nil then if obj:get_luaentity().name ~= self.name and obj:get_luaentity().name ~= "__builtin:item" then --something other found @@ -333,7 +333,7 @@ function cannons.register_muni(node,entity) end end cannons.registered_muni[node].obj = entity.name - minetest.register_entity(entity.name, cannons.registered_muni[node].entity) + core.register_entity(entity.name, cannons.registered_muni[node].entity) end function cannons.is_muni(node) @@ -372,9 +372,9 @@ function cannons.on_ball_punch(pos, node, puncher, pointed_thing) puncher:get_inventory():add_item('main', item) if level > 1 then node.name = item.."_stack_"..level-1 - minetest.swap_node(pos,node); + core.swap_node(pos,node); else - minetest.remove_node(pos); + core.remove_node(pos); end end @@ -390,7 +390,7 @@ function cannons.on_ball_rightclick(pos, node, player, itemstack, pointed_thing) if level < 5 then itemstack:take_item(1) node.name = item.."_stack_"..level+1 - minetest.swap_node(pos,node); + core.swap_node(pos,node); return itemstack; else return itemstack @@ -399,7 +399,7 @@ function cannons.on_ball_rightclick(pos, node, player, itemstack, pointed_thing) end function cannons.generate_and_register_ball_node(name,nodedef) - minetest.register_alias(name, name.."_stack_1"); + core.register_alias(name, name.."_stack_1"); nodedef.drawtype = "nodebox"; nodedef.selection_box = nil; nodedef.on_punch = cannons.on_ball_punch; @@ -417,10 +417,10 @@ function cannons.generate_and_register_ball_node(name,nodedef) nodedef["drop"] = name.."_stack_1 "..number;--set drop nodedef.name = name.."_stack_"..number;--set name - minetest.register_node(nodedef.name, table.copy(nodedef))--register node + core.register_node(nodedef.name, table.copy(nodedef))--register node end --register craft, to allow craft 5-stacks - minetest.register_craft({ + core.register_craft({ type = "shapeless", output = name.."_stack_5", recipe = { name,name,name,name,name}, @@ -515,14 +515,14 @@ local apple={ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_player(playername ," this is not an easter egg!") + core.chat_send_player(playername ," this is not an easter egg!") end, on_mob_hit = function(self,pos,mob) self.object:remove() end, on_node_hit = function(self,pos,node) - minetest.env:set_node({x=self.lastpos.x, y=self.lastpos.y, z=self.lastpos.z},{name="default:apple"}) - minetest.sound_play("canons_hit", + core.env:set_node({x=self.lastpos.x, y=self.lastpos.y, z=self.lastpos.z},{name="default:apple"}) + core.sound_play("canons_hit", {pos = self.lastpos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end, diff --git a/init.lua b/init.lua index a3674dc..36e8644 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ cannons = {} -cannons.MODPATH = minetest.get_modpath(minetest.get_current_modname()) -local worldpath = minetest.get_worldpath() +cannons.MODPATH = core.modpath(core.get_current_modname()) +local worldpath = core.get_worldpath() cannons.config = Settings(worldpath.."/cannons.conf") local conf_table = cannons.config:to_table() @@ -26,18 +26,18 @@ if cannons.config:get_bool("convert_old_nodes") then dofile(cannons.MODPATH .."/convert.lua") end -if minetest.get_modpath("tnt") then - minetest.log("info","TNT mod is aviable. registering some TNT stuff") +if core.get_modpath("tnt") then + core.log("info","TNT mod is aviable. registering some TNT stuff") dofile(cannons.MODPATH .."/tnt.lua") end -if minetest.get_modpath("locks") then - minetest.log("warning","locks mod enabled. dont execute locks.lua because this is an unstable beta version!") +if core.get_modpath("locks") then + core.log("warning","locks mod enabled. dont execute locks.lua because this is an unstable beta version!") --dofile(cannons.MODPATH .."/locks.lua")--if the locks mod is installed execute this file end -if minetest.get_modpath("moreores") then -minetest.log("info","moreores mod enabled. execute moreores.lua") +if core.get_modpath("moreores") then +core.log("info","moreores mod enabled. execute moreores.lua") dofile(cannons.MODPATH .."/moreores.lua")--if the moreores mod is installed execute this file end -minetest.log("info", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname())) +core.log("info", "[MOD]"..core.get_current_modname().." -- loaded from "..core.get_modpath(core.get_current_modname())) diff --git a/items.lua b/items.lua index 123a973..f5c5f9a 100644 --- a/items.lua +++ b/items.lua @@ -2,19 +2,19 @@ --+ Craft Items + --++++++++++++++++++++++++++++++++++++ -minetest.register_craftitem("cannons:gunpowder", { +core.register_craftitem("cannons:gunpowder", { groups = {gunpowder=1}, description = "Gunpowder", inventory_image = "cannons_gunpowder.png" }) cannons.register_gunpowder("cannons:gunpowder"); -minetest.register_craftitem("cannons:salt", { +core.register_craftitem("cannons:salt", { description = "Salt", inventory_image = "cannons_salt.png" }) -minetest.register_craftitem("cannons:bucket_salt", { +core.register_craftitem("cannons:bucket_salt", { description = "Bucket with salt", inventory_image = "cannons_bucket_salt.png", stack_max = 300 @@ -25,7 +25,7 @@ minetest.register_craftitem("cannons:bucket_salt", { --+ crafts + --++++++++++++++++++++++++++++++++++++ -minetest.register_craft({ +core.register_craft({ type = "shapeless", output = 'cannons:salt 12', recipe = { @@ -36,14 +36,14 @@ minetest.register_craft({ } }) -minetest.register_craft({ +core.register_craft({ type = "cooking", output = 'cannons:bucket_salt', recipe = 'bucket:bucket_water', cooktime = 15 }) -minetest.register_craft({ +core.register_craft({ type = "shapeless", output = 'cannons:gunpowder', recipe = { @@ -54,7 +54,7 @@ minetest.register_craft({ -- new crafts -- -minetest.register_craft({ +core.register_craft({ output = "cannons:cannon_steel", recipe = { {"default:steelblock", "default:steelblock", "default:steelblock"}, @@ -63,7 +63,7 @@ minetest.register_craft({ }, }) -minetest.register_craft({ +core.register_craft({ output = "cannons:cannon_bronze", recipe = { {"default:bronzeblock", "default:bronzeblock", "default:bronzeblock"}, @@ -72,7 +72,7 @@ minetest.register_craft({ }, }) ---minetest.register_craft({ +--core.register_craft({ -- output = 'cannons:stand', -- recipe = { -- {"default:wood", "", "default:wood"}, @@ -81,7 +81,7 @@ minetest.register_craft({ -- }, --}) -minetest.register_craft({ +core.register_craft({ output = 'cannons:wood_stand', recipe = { {"default:wood", "", "default:wood"}, @@ -92,7 +92,7 @@ minetest.register_craft({ -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_wood 5', recipe = { {"","default:wood",""}, @@ -101,14 +101,14 @@ minetest.register_craft({ }, }) -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_stone', recipe = { {"default:stone"}, }, }) -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_steel 2', recipe = { {"", "default:steel_ingot",""}, @@ -118,7 +118,7 @@ minetest.register_craft({ }) if cannons.config:get_bool("enable_explosion") then -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_exploding 2', recipe = { {"","default:mese",""}, @@ -129,7 +129,7 @@ minetest.register_craft({ end if cannons.config:get_bool("enable_fire") then -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_fire 2', recipe = { {"","default:wood",""}, @@ -143,7 +143,7 @@ end --++++++++++++++++++++++++++++++++++++ --steel cannon -minetest.register_node("cannons:cannon_steel", { +core.register_node("cannons:cannon_steel", { description = "steel cannon", stack_max = 1, --tiles = {"cannon_cannon_top.png","cannon_cannon_top.png","cannon_cannon_side.png","cannon_cannon_side.png","cannon_cannon_top.png^cannons_rim.png","cannon_cannon_side.png"}, @@ -170,7 +170,7 @@ minetest.register_node("cannons:cannon_steel", { }) --bronze cannon -minetest.register_node("cannons:cannon_bronze", { +core.register_node("cannons:cannon_bronze", { description = "bronze cannon", stack_max = 1, --tiles = {"cannon_cannon_top.png","cannon_cannon_top.png","cannon_cannon_side.png","cannon_cannon_side.png","cannon_cannon_top.png^cannons_rim.png","cannon_cannon_side.png"}, @@ -196,7 +196,7 @@ minetest.register_node("cannons:cannon_bronze", { on_metadata_inventory_move = cannons.inventory_modified, }) -minetest.register_node("cannons:wood_stand", { +core.register_node("cannons:wood_stand", { description = "Wooden cannon stand", stack_max = 9, --tiles = side other @@ -213,7 +213,7 @@ minetest.register_node("cannons:wood_stand", { on_rightclick = cannons.stand_on_rightclick }) -minetest.register_node("cannons:ship_stand", { +core.register_node("cannons:ship_stand", { description = "Wooden cannon stand", stack_max = 9, --tiles = wheel material side @@ -231,7 +231,7 @@ minetest.register_node("cannons:ship_stand", { }) --wooden stand with steel cannon --in German: Holzständer mit Stahkanone -minetest.register_node("cannons:wood_stand_with_cannon_steel", { +core.register_node("cannons:wood_stand_with_cannon_steel", { description = "wooden stand with steel cannon", cannons ={stand="cannons:wood_stand",cannon="cannons:cannon_steel"}, stack_max = 0, @@ -257,7 +257,7 @@ minetest.register_node("cannons:wood_stand_with_cannon_steel", { on_metadata_inventory_move = cannons.inventory_modified, }) -minetest.register_node("cannons:ship_stand_with_cannon_steel", { +core.register_node("cannons:ship_stand_with_cannon_steel", { description = "ship stand with steel cannon", cannons ={stand="cannons:ship_stand",cannon="cannons:cannon_steel"}, stack_max = 0, @@ -283,7 +283,7 @@ minetest.register_node("cannons:ship_stand_with_cannon_steel", { on_metadata_inventory_move = cannons.inventory_modified, }) -minetest.register_node("cannons:ship_stand_with_cannon_bronze", { +core.register_node("cannons:ship_stand_with_cannon_bronze", { description = "ship stand with bronze cannon", cannons ={stand="cannons:ship_stand",cannon="cannons:cannon_bronze"}, stack_max = 0, @@ -310,7 +310,7 @@ minetest.register_node("cannons:ship_stand_with_cannon_bronze", { }) --wooden stand with bronze cannon -- --in German: Holzständer mit Bronzekanone -minetest.register_node("cannons:wood_stand_with_cannon_bronze", { +core.register_node("cannons:wood_stand_with_cannon_bronze", { description = "wooden stand with bronze cannon", cannons ={stand="cannons:wood_stand",cannon="cannons:cannon_bronze"}, stack_max = 0, diff --git a/locks.lua b/locks.lua index 9aff4d1..b70b07b 100644 --- a/locks.lua +++ b/locks.lua @@ -3,7 +3,7 @@ --++++++++++++++++++++++++++++++++++++ -minetest.register_node("cannons:shared_locked_cannon", { +core.register_node("cannons:shared_locked_cannon", { description = "locked shareable Cannon", stack_max = 1, tiles = {"cannon_cannon_top.png","cannon_cannon_top.png","cannon_cannon_side.png","cannon_cannon_side.png","cannon_cannon_top.png^cannons_rim.png","cannon_cannon_side.png"}, @@ -30,7 +30,7 @@ minetest.register_node("cannons:shared_locked_cannon", { --}, on_construct = cannons.on_construct_locks, can_dig = function(pos,player) - local meta = minetest.get_meta(pos); + local meta = core.get_meta(pos); local inv = meta:get_inventory() if not inv:is_empty("gunpowder") then return false @@ -57,7 +57,7 @@ minetest.register_node("cannons:shared_locked_cannon", { }) -minetest.register_craft({ +core.register_craft({ output = 'cannons:shared_locked_cannon', recipe = { {'group:cannon', 'locks:lock',}, diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..612c760 --- /dev/null +++ b/mod.conf @@ -0,0 +1,9 @@ +name = cannons +title = Cannons +depends = default, bucket +optional_depends = mesecons, locks, moreores, tnt +description = """ +Adds cannons to Minetest Game. +To shoot, insert munitions and gunpowder and punch the cannon with a torch. +The projectiles can destroy nodes and hurt players. +""" diff --git a/moreores.lua b/moreores.lua index c362081..64466f4 100644 --- a/moreores.lua +++ b/moreores.lua @@ -1,5 +1,5 @@ --mithril cannon -minetest.register_node("cannons:cannon_mithril", { +core.register_node("cannons:cannon_mithril", { description = "mithril cannon", stack_max = 1, tiles = {"cannons_mithril_top.png","cannons_mithril_side.png"}, @@ -24,7 +24,7 @@ minetest.register_node("cannons:cannon_mithril", { }) --wood stand with mithril cannon -minetest.register_node("cannons:wood_stand_with_cannon_mithril", { +core.register_node("cannons:wood_stand_with_cannon_mithril", { description = "wooden stand with mithril cannon", cannons ={stand="cannons:wood_stand",cannon="cannons:cannon_mithril"}, stack_max = 0, @@ -50,7 +50,7 @@ minetest.register_node("cannons:wood_stand_with_cannon_mithril", { on_metadata_inventory_move = cannons.inventory_modified, }) --ship_stand with mithril cannon -minetest.register_node("cannons:ship_stand_with_cannon_mithril", { +core.register_node("cannons:ship_stand_with_cannon_mithril", { description = "ship stand with mithril cannon", cannons ={stand="cannons:ship_stand",cannon="cannons:cannon_mithril"}, stack_max = 0, @@ -76,7 +76,7 @@ minetest.register_node("cannons:ship_stand_with_cannon_mithril", { on_metadata_inventory_move = cannons.inventory_modified, }) --craft reziep mithrill cannon -minetest.register_craft({ +core.register_craft({ output = "cannons:cannon_mithril", recipe = { {"moreores:mithril_block", "moreores:mithril_block", "moreores:mithril_block"}, @@ -98,7 +98,7 @@ cannons.generate_and_register_ball_node("cannons:ball_mithril", { node_box = cannons.nodeboxes.ball, }) -minetest.register_craft({ +core.register_craft({ output = 'cannons:ball_mithril', recipe = { {"moreores:mithril_block"} @@ -124,7 +124,7 @@ cannons.register_muni("cannons:ball_mithril_stack_1",{ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_all(playername .." tried to catch a canonball") + core.chat_send_all(playername .." tried to catch a canonball") end, on_mob_hit = function(self,pos,mob) mob:punch(self.object, 1.0, { @@ -136,16 +136,16 @@ cannons.register_muni("cannons:ball_mithril_stack_1",{ on_node_hit = function(self,pos,node) cannons.nodehitparticles(pos,node) if node.name == "default:dirt_with_grass" then - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) - minetest.sound_play("cannons_hit", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() elseif node.name == "default:water_source" then - minetest.sound_play("cannons_splash", + core.sound_play("cannons_splash", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() else - minetest.sound_play("cannons_hit", + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end diff --git a/readme.md b/readme.md index 4f6661b..2a48adb 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Welcome to the cannons mod # -cannons is a mod for the game minetest written by Kingarthurs Team +cannons is a mod for minetest game written by Kingarthurs Team (Semmett9, eythen, and addi) if you have some muni in the cannon and some gunpowder @@ -98,7 +98,7 @@ local ball_wood={ damage_groups={fleshy=self.damage}, }, nil) self.object:remove() - minetest.chat_send_all(playername .." tried to catch a cannonball") + core.chat_send_all(playername .." tried to catch a cannonball") end, on_mob_hit = function(self,pos,mob) mob:punch(self.object, 1.0, { @@ -109,16 +109,16 @@ local ball_wood={ end, on_node_hit = function(self,pos,node) if node.name == "default:dirt_with_grass" then - minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) - minetest.sound_play("cannons_hit", + core.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"}) + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() elseif node.name == "default:water_source" then - minetest.sound_play("cannons_splash", + core.sound_play("cannons_splash", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() else - minetest.sound_play("cannons_hit", + core.sound_play("cannons_hit", {pos = pos, gain = 1.0, max_hear_distance = 32,}) self.object:remove() end diff --git a/tnt.lua b/tnt.lua index a2539de..1c87c91 100644 --- a/tnt.lua +++ b/tnt.lua @@ -11,15 +11,15 @@ cannons.register_muni("tnt:tnt",{ velocity=20, collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25}, on_player_hit = function(self,pos,player) - minetest.registered_nodes["tnt:tnt_burning"].on_timer(pos); + core.registered_nodes["tnt:tnt_burning"].on_timer(pos); self.object:remove() end, on_mob_hit = function(self,pos,mob) - minetest.registered_nodes["tnt:tnt_burning"].on_timer(pos); + core.registered_nodes["tnt:tnt_burning"].on_timer(pos); self.object:remove() end, on_node_hit = function(self,pos,node) - minetest.registered_nodes["tnt:tnt_burning"].on_timer(pos); + core.registered_nodes["tnt:tnt_burning"].on_timer(pos); self.object:remove() end, })