diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 diff --git a/README.txt b/README.txt old mode 100644 new mode 100755 diff --git a/depends.txt b/depends.txt old mode 100644 new mode 100755 diff --git a/init.lua b/init.lua old mode 100644 new mode 100755 index 183eb73..14fed85 --- a/init.lua +++ b/init.lua @@ -1,37 +1,34 @@ -local BALL_PUSH_CHECK_INTERVAL = 0.1 - local function reg_ball(color) - - local ball_item_name = "soccer:ball_"..color.."_item" - local ball_ent_name = "soccer:ball_"..color.."_entity" + local ball_item_name = "soccer:ball_" .. color .. "_item" + local ball_ent_name = "soccer:ball_" .. color .. "_entity" minetest.register_entity(ball_ent_name, { physical = true, + hp_max = 32767, + collide_with_objects = false, visual = "mesh", + visual_size = {x = 1.125, y = 1.125, z = 1.125}, mesh = "soccer_ball.x", - hp_max = 1000, - groups = { immortal = true }, - textures = { "soccer_ball_"..color..".png" }, - collisionbox = { -0.2, -0.2, -0.2, 0.2, 0.2, 0.2 }, - + groups = {immortal = true}, + textures = {"soccer_ball_" .. color .. ".png"}, + collisionbox = { -0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, timer = 0, on_step = function(self, dtime) self.timer = self.timer + dtime - if self.timer >= BALL_PUSH_CHECK_INTERVAL then - self.object:setacceleration({x=0, y=-10, z=0}) + if self.timer >= 0.2 then + self.object:setacceleration({x = 0, y = -14.5, z = 0}) self.timer = 0 local vel = self.object:getvelocity() local p = self.object:getpos(); p.y = p.y - 0.5 if minetest.registered_nodes[minetest.env:get_node(p).name].walkable then - vel.x = vel.x * 0.85 - if vel.y < 0 then vel.y = vel.y * -0.65 end - vel.z = vel.z * 0.90 + vel.x = vel.x * 0.9 + if vel.y < 0 then vel.y = vel.y * -0.6 end + vel.z = vel.z * 0.9 end - if (math.abs(vel.x) < 0.1) - and (math.abs(vel.z) < 0.1) then + if (math.abs(vel.x) <= 0.1) and (math.abs(vel.z) <= 0.1) then vel.x = 0 vel.z = 0 end @@ -39,14 +36,12 @@ local function reg_ball(color) local pos = self.object:getpos() local objs = minetest.env:get_objects_inside_radius(pos, 1) local player_count = 0 - local final_dir = { x=0, y=0, z=0 } + local final_dir = {x = 0, y = 0, z = 0} for _,obj in ipairs(objs) do if obj:is_player() then local objdir = obj:get_look_dir() local mul = 1 - if (obj:get_player_control().sneak) then - mul = 3 - end + if (obj:get_player_control().sneak) then mul = 2 end final_dir.x = final_dir.x + (objdir.x * mul) final_dir.y = final_dir.y + (objdir.y * mul) final_dir.z = final_dir.z + (objdir.z * mul) @@ -54,10 +49,11 @@ local function reg_ball(color) end end if final_dir.x ~= 0 or final_dir.y ~= 0 or final_dir.z ~= 0 then - final_dir.x = (final_dir.x * 5) / player_count - final_dir.y = (final_dir.y * 5) / player_count - final_dir.z = (final_dir.z * 5) / player_count + final_dir.x = (final_dir.x * 7.2) / player_count + final_dir.y = (final_dir.y * 9.6) / player_count + final_dir.z = (final_dir.z * 7.2) / player_count self.object:setvelocity(final_dir) + minetest.sound_play("default_dig_oddly_breakable_by_hand", {object = self.object, gain = 0.5}) end end end, @@ -72,8 +68,7 @@ local function reg_ball(color) is_moving = function(self) local v = self.object:getvelocity() - if (math.abs(v.x) <= 0.1) - and (math.abs(v.z) <= 0.1) then + if (math.abs(v.x) <= 0.1) and (math.abs(v.z) <= 0.1) then v.x = 0 v.z = 0 self.object:setvelocity(v) @@ -86,22 +81,28 @@ local function reg_ball(color) minetest.register_craftitem(ball_item_name, { description = "Soccer Ball ("..color..")", inventory_image = "soccer_ball_"..color.."_inv.png", - + wield_scale = {x = 0.75, y = 0.75, z = 4.5}, on_place = function(itemstack, placer, pointed_thing) local pos = pointed_thing.above - --pos = { x=pos.x+0.5, y=pos.y, z=pos.z+0.5 } + -- pos = { x =pos.x + 0.5, y = pos.y, z = pos.z + 0.5 } local ent = minetest.env:add_entity(pos, ball_ent_name) - ent:setvelocity({x=0, y=-15, z=0}) - itemstack:take_item() + minetest.log("action", placer:get_player_name() .. " placed a ball at " .. minetest.pos_to_string(pointed_thing.above) .. ".") + ent:setvelocity({x = 0, y = -14.5, z = 0}) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end return itemstack end, }) + if color == "purple" then + color = "pink" + end minetest.register_craft({ output = ball_item_name, recipe = { { "", "wool:white", "" }, - { "wool:white", "wool:"..color, "wool:white" }, + { "wool:white", "wool:" .. color, "wool:white" }, { "", "wool:white", "" }, }, }) @@ -116,64 +117,8 @@ for _,color in ipairs(colors) do reg_ball(color) end -minetest.register_node("soccer:goal", { - description = "Soccer Goal", - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - tiles = { "soccer_white.png" }, - sunlight_propagates = true, - groups = { snappy=1, cracky=1, fleshy=1, oddly_breakable_by_hand=1 }, - node_box = { - type = "fixed", - fixed = { - { -2.5, -0.5, -0.1, -2.3, 1.5, 0.1 }, - { 2.3, -0.5, -0.1, 2.5, 1.5, 0.1 }, - { -2.5, 1.5, -0.1, 2.5, 1.7, 0.1 }, - }, - }, -}) +minetest.register_alias("ball", "soccer:ball_black_item") -- For quickly using the /give command. -local nb_decal = { - type = "fixed", - fixed = {{ -0.5, -0.5, -0.5, 0.5, -0.499, 0.5 }}, -}, - -minetest.register_node("soccer:goal_mark", { - description = "Soccer Goal Mark", - drawtype = "nodebox", - paramtype = "light", - node_box = nb_decal, - walkable = false, - inventory_image = "soccer_goal_mark.png", - tiles = { "soccer_goal_mark.png" }, - sunlight_propagates = true, - groups = { snappy=1, cracky=1, fleshy=1, oddly_breakable_by_hand=1 }, -}) - -local function reg_decal(name, desc) - texture = "soccer_"..name..".png" - minetest.register_node("soccer:"..name, { - description = desc, - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - node_box = nb_decal, - walkable = false, - inventory_image = texture, - wield_image = texture, - tiles = { texture }, - sunlight_propagates = true, - groups = { snappy=1, cracky=1, fleshy=1, oddly_breakable_by_hand=1 }, - }) +if minetest.setting_getbool("log_mods") then + minetest.log("action", "Carbone: [soccer] loaded.") end - -reg_decal("line_i", "Straight Line") -reg_decal("line_l", "L line") -reg_decal("line_t", "T Line") -reg_decal("line_p", "+ Line") -reg_decal("line_d", "Diagonal Line") -reg_decal("line_point", "Point") -reg_decal("line_corner", "Corner") - -minetest.register_alias("ball", "soccer:ball_item_black") diff --git a/models/soccer_ball.x b/models/soccer_ball.x old mode 100644 new mode 100755 diff --git a/textures/soccer_ball_black.png b/textures/soccer_ball_black.png old mode 100644 new mode 100755 index ca66fb9..d9baa4c Binary files a/textures/soccer_ball_black.png and b/textures/soccer_ball_black.png differ diff --git a/textures/soccer_ball_black_inv.png b/textures/soccer_ball_black_inv.png index dd7c812..3904937 100644 Binary files a/textures/soccer_ball_black_inv.png and b/textures/soccer_ball_black_inv.png differ diff --git a/textures/soccer_ball_blue.png b/textures/soccer_ball_blue.png old mode 100644 new mode 100755 index 0cca107..01d9275 Binary files a/textures/soccer_ball_blue.png and b/textures/soccer_ball_blue.png differ diff --git a/textures/soccer_ball_blue_inv.png b/textures/soccer_ball_blue_inv.png index 89e0213..ade67cf 100644 Binary files a/textures/soccer_ball_blue_inv.png and b/textures/soccer_ball_blue_inv.png differ diff --git a/textures/soccer_ball_green.png b/textures/soccer_ball_green.png old mode 100644 new mode 100755 index e2eefcc..9ed01b8 Binary files a/textures/soccer_ball_green.png and b/textures/soccer_ball_green.png differ diff --git a/textures/soccer_ball_green_inv.png b/textures/soccer_ball_green_inv.png index f6068d8..d748637 100644 Binary files a/textures/soccer_ball_green_inv.png and b/textures/soccer_ball_green_inv.png differ diff --git a/textures/soccer_ball_purple.png b/textures/soccer_ball_purple.png old mode 100644 new mode 100755 index 6d834ec..5c8c4f4 Binary files a/textures/soccer_ball_purple.png and b/textures/soccer_ball_purple.png differ diff --git a/textures/soccer_ball_purple_inv.png b/textures/soccer_ball_purple_inv.png index 91f48ee..ed4f34a 100644 Binary files a/textures/soccer_ball_purple_inv.png and b/textures/soccer_ball_purple_inv.png differ diff --git a/textures/soccer_ball_red.png b/textures/soccer_ball_red.png old mode 100644 new mode 100755 index 30d4a5f..81bf462 Binary files a/textures/soccer_ball_red.png and b/textures/soccer_ball_red.png differ diff --git a/textures/soccer_ball_red_inv.png b/textures/soccer_ball_red_inv.png index 48aff7a..f0fcdfb 100644 Binary files a/textures/soccer_ball_red_inv.png and b/textures/soccer_ball_red_inv.png differ diff --git a/textures/soccer_ball_yellow.png b/textures/soccer_ball_yellow.png old mode 100644 new mode 100755 index 8f34080..582c183 Binary files a/textures/soccer_ball_yellow.png and b/textures/soccer_ball_yellow.png differ diff --git a/textures/soccer_ball_yellow_inv.png b/textures/soccer_ball_yellow_inv.png index 6171164..1589af0 100644 Binary files a/textures/soccer_ball_yellow_inv.png and b/textures/soccer_ball_yellow_inv.png differ diff --git a/textures/soccer_goal_mark.png b/textures/soccer_goal_mark.png deleted file mode 100644 index 5d0a19b..0000000 Binary files a/textures/soccer_goal_mark.png and /dev/null differ diff --git a/textures/soccer_line_corner.png b/textures/soccer_line_corner.png deleted file mode 100644 index fc8fd65..0000000 Binary files a/textures/soccer_line_corner.png and /dev/null differ diff --git a/textures/soccer_line_d.png b/textures/soccer_line_d.png deleted file mode 100644 index 67cc7b8..0000000 Binary files a/textures/soccer_line_d.png and /dev/null differ diff --git a/textures/soccer_line_i.png b/textures/soccer_line_i.png deleted file mode 100644 index f0ea865..0000000 Binary files a/textures/soccer_line_i.png and /dev/null differ diff --git a/textures/soccer_line_l.png b/textures/soccer_line_l.png deleted file mode 100644 index 92fa84e..0000000 Binary files a/textures/soccer_line_l.png and /dev/null differ diff --git a/textures/soccer_line_p.png b/textures/soccer_line_p.png deleted file mode 100644 index aca6555..0000000 Binary files a/textures/soccer_line_p.png and /dev/null differ diff --git a/textures/soccer_line_point.png b/textures/soccer_line_point.png deleted file mode 100644 index cf7d23c..0000000 Binary files a/textures/soccer_line_point.png and /dev/null differ diff --git a/textures/soccer_line_t.png b/textures/soccer_line_t.png deleted file mode 100644 index a18cadd..0000000 Binary files a/textures/soccer_line_t.png and /dev/null differ diff --git a/textures/soccer_white.png b/textures/soccer_white.png deleted file mode 100644 index 5a983c9..0000000 Binary files a/textures/soccer_white.png and /dev/null differ