From 235fc357518c8d88307b0b46a0d9bd28993afabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Mon, 27 May 2013 10:28:15 -0300 Subject: [PATCH] Various fixes and additions --- init.lua | 103 ++++++++++++++++++-------------- textures/soccer_ball.png | Bin 0 -> 180 bytes textures/soccer_ball_inv.png | Bin 0 -> 193 bytes textures/soccer_line_corner.png | Bin 0 -> 130 bytes textures/soccer_line_d.png | Bin 0 -> 118 bytes textures/soccer_line_i.png | Bin 0 -> 86 bytes textures/soccer_line_l.png | Bin 0 -> 101 bytes textures/soccer_line_p.png | Bin 0 -> 97 bytes textures/soccer_line_point.png | Bin 0 -> 105 bytes textures/soccer_line_t.png | Bin 0 -> 94 bytes 10 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 textures/soccer_ball.png create mode 100644 textures/soccer_ball_inv.png create mode 100644 textures/soccer_line_corner.png create mode 100644 textures/soccer_line_d.png create mode 100644 textures/soccer_line_i.png create mode 100644 textures/soccer_line_l.png create mode 100644 textures/soccer_line_p.png create mode 100644 textures/soccer_line_point.png create mode 100644 textures/soccer_line_t.png diff --git a/init.lua b/init.lua index 55695e5..eb7ad8f 100644 --- a/init.lua +++ b/init.lua @@ -7,25 +7,27 @@ minetest.register_entity("soccer:ball", { mesh = "soccer_ball.x", hp_max = 1000, groups = { immortal = true }, - textures = { "wool_white.png" }, + textures = { "soccer_ball.png" }, collisionbox = { -0.2, -0.2, -0.2, 0.2, 0.2, 0.2 }, 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}) self.timer = 0 - if self:is_moving() then - local p = self.object:getpos(); - p.y = p.y - 0.5 - local walkable = minetest.registered_nodes[minetest.env:get_node(p).name].walkable - print("walkable: "..tostring(walkable)) - if walkable then - local vel = self.object:getvelocity() - vel.x = vel.x * 0.80 - vel.z = vel.z * 0.80 - self.object:setvelocity(vel) - --return - end + 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.80 + if vel.y < 0 then vel.y = vel.y * -0.50 end + vel.z = vel.z * 0.80 end + if (math.abs(vel.x) < 0.1) + and (math.abs(vel.z) < 0.1) then + vel.x = 0 + vel.z = 0 + end + self.object:setvelocity(vel) local pos = self.object:getpos() local objs = minetest.env:get_objects_inside_radius(pos, 1) local player_count = 0 @@ -47,13 +49,7 @@ minetest.register_entity("soccer:ball", { 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 - local accel = { - x = 0, - y = -(final_dir.y / 2) - 4, - z = 0, - } self.object:setvelocity(final_dir) - self.object:setacceleration(accel) end end end, @@ -67,9 +63,10 @@ minetest.register_entity("soccer:ball", { is_moving = function(self) local v = self.object:getvelocity() if (math.abs(v.x) <= 0.1) - and (math.abs(v.y) <= 0.1) and (math.abs(v.z) <= 0.1) then - self.object:setvelocity({x=0, y=0, z=0}) + v.x = 0 + v.z = 0 + self.object:setvelocity(v) return false end return true @@ -79,7 +76,7 @@ minetest.register_entity("soccer:ball", { minetest.register_craftitem("soccer:ball_item", { description = "Soccer Ball", - inventory_image = "default_sand.png", + inventory_image = "soccer_ball_inv.png", 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 } @@ -108,10 +105,16 @@ minetest.register_node("soccer:goal", { }, }) +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 = "raillike", + drawtype = "nodebox", paramtype = "light", + node_box = nb_decal, walkable = false, inventory_image = "soccer_goal_mark.png", tiles = { "soccer_goal_mark.png" }, @@ -119,30 +122,38 @@ minetest.register_node("soccer:goal_mark", { groups = { snappy=1, cracky=1, fleshy=1, oddly_breakable_by_hand=1 }, }) -soccer = {} - -soccer.matches = { count = 0 } - -function soccer:create_match() - for n = 1, self.matches.count do - if not self.matches[id] then - self.matches[id] = { - players = { }, - } - return id - end - end +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 }, + }) end -function soccer:match_score(id, player) - -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_node("soccer:controller", { - description = "Soccer Goal Mark", - drawtype = "raillike", - paramtype = "light", - tiles = { "soccer_goal_mark.png" }, - sunlight_propagates = true, - groups = { snappy=1, cracky=1, fleshy=1, oddly_breakable_by_hand=1 }, +minetest.register_craft({ + output = "soccer:ball_item", + recipe = { + { "", "wool:white", "" }, + { "wool:white", "default:coal_lump", "wool:white" }, + { "", "wool:white", "" }, + }, }) + +minetest.register_alias("ball", "soccer:ball_item") diff --git a/textures/soccer_ball.png b/textures/soccer_ball.png new file mode 100644 index 0000000000000000000000000000000000000000..ca66fb95770633c32f0aa70dd31c9d261c8bb03d GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#E~_+ysmRpyHzhzJ+02lL66gHf+|)b}mw~~#C^fMpHASI3vm`^o-P1Q9MK6^d zD6Zw{;uxZFJ~_pK>Hq)#?VBYfB{y~%8&2TJSl>8NqFlL~-_5?~*x>~qm>En0B*bmj Rxq;lr;OXk;vd$@?2>{1lF1!E$ literal 0 HcmV?d00001 diff --git a/textures/soccer_ball_inv.png b/textures/soccer_ball_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..dd7c812e480a05abe386f9eff91e1f2be145afc3 GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`9iA?ZAr`$;Cp(HARp4N5-*@l- zsh6kXdjkI6bezc%))bZXX`?rX!>pej4nl$(3vN2_rQIlQmSsDo&anhu`m1Ic$lx*9DXYKm+TbR_@6TRFVdQ&MBb@00vS{7ytkO literal 0 HcmV?d00001 diff --git a/textures/soccer_line_corner.png b/textures/soccer_line_corner.png new file mode 100644 index 0000000000000000000000000000000000000000..fc8fd655806ba987f7c2a44eb945c52881112954 GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`o}Mm_Ar`&K2@bP0l+XkK;w&aX literal 0 HcmV?d00001 diff --git a/textures/soccer_line_d.png b/textures/soccer_line_d.png new file mode 100644 index 0000000000000000000000000000000000000000..67cc7b86359165df3a22e77f504f5d7cc76e6c95 GIT binary patch literal 118 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`ww^AIAr`%F&shsG2neuTy!Tta z%7uyRx1iC_*HS;KYbT|cODqt1u|q^+!_1{j#(uUD4+|37og0PAnB~|qly)osEx)v5 Q3(z12Pgg&ebxsLQ09#Ha5C8xG literal 0 HcmV?d00001 diff --git a/textures/soccer_line_i.png b/textures/soccer_line_i.png new file mode 100644 index 0000000000000000000000000000000000000000..f0ea8655661a1a41bcf1da4127012cc28f86ff72 GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vYsxEAr`&K2@_^@m^N?$H65vE5n()&a~r6S!PC{xWt~$(69C)%8`l5; literal 0 HcmV?d00001 diff --git a/textures/soccer_line_p.png b/textures/soccer_line_p.png new file mode 100644 index 0000000000000000000000000000000000000000..aca65552aa81a0c11665ddfd2776988969ec75ee GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`8lEnWAr`&K2?v<}IWyXs`utGo uWL(S^aFD^x>7q-q_yg9(oS7>m7#J>9iE#9m+~5c5VeoYIb6Mw<&;$TB4;hyL literal 0 HcmV?d00001 diff --git a/textures/soccer_line_point.png b/textures/soccer_line_point.png new file mode 100644 index 0000000000000000000000000000000000000000..cf7d23c449c76ec94af43f7ad63918cdc756d2c8 GIT binary patch literal 105 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`2A(dCAr`&K2@gTe~DWM4f4;LAt literal 0 HcmV?d00001