Compare commits

...

6 Commits

Author SHA1 Message Date
b9048f34b0 deprecation 2022-08-18 17:04:29 +02:00
257c1e0be8 fix deprecation 2022-08-18 17:00:24 +02:00
db20ba0317 fix portalgun being in item list 2022-08-18 16:45:08 +02:00
bb2f30a721 _ 2022-08-14 20:18:23 +02:00
d89538d0a2 im dumb 2022-08-14 16:05:38 +02:00
910d9e0979 _ 2022-08-14 16:00:16 +02:00
4 changed files with 111 additions and 18 deletions

View File

@@ -412,6 +412,9 @@ minetest.register_craftitem(
range = 100, range = 100,
inventory_image = "portalgun_gun0_rndr.png", inventory_image = "portalgun_gun0_rndr.png",
wield_image = "portalgun_gun0_rndr.png", wield_image = "portalgun_gun0_rndr.png",
groups = {not_in_creative_inventory = 1},
--inventory_image = "portalgun_gun_orange.png",
--wield_image = "portalgun_gun_orange.png",
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
if node.name == "portalgun:button" then if node.name == "portalgun:button" then

View File

@@ -3,7 +3,51 @@ minetest.register_node(
{ {
description = "Toxic water", description = "Toxic water",
drawtype = "liquid", drawtype = "liquid",
tiles = {"portalgun_toxwat.png"}, waving = 3,
tiles = {
{
name = "portal_toxwater_anim.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
{
name = "portal_toxwater_anim.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
},
special_tiles = {
{
name = "portal_toxwater_anim.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
{
name = "portal_toxwater_anim.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
},
use_texture_alpha = "blend", use_texture_alpha = "blend",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
@@ -30,10 +74,50 @@ minetest.register_node(
{ {
description = "Toxic water 2", description = "Toxic water 2",
drawtype = "flowingliquid", drawtype = "flowingliquid",
tiles = {name = "portalgun_toxwat.png", backface_culling = false}, waving = 3,
tiles = {
{
name = "portal_toxwater_anim.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
{
name = "portal_toxwater_anim.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
},
special_tiles = { special_tiles = {
{name = "portalgun_toxwat.png", backface_culling = true}, {
{name = "portalgun_toxwat.png", backface_culling = false} name = "portal_toxwater_anim.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
{
name = "portal_toxwater_anim.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 8.0,
},
},
}, },
use_texture_alpha = "blend", use_texture_alpha = "blend",
paramtype = "light", paramtype = "light",

View File

@@ -86,7 +86,7 @@ minetest.register_entity(
self._tmr = self._tmr + elapsed self._tmr = self._tmr + elapsed
self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360))) self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360)))
--get yaw and convert it into param2 --get yaw and convert it into param2
local p = self.object:getyaw() local p = self.object:get_yaw()
--convert yaw from rad to degrees --convert yaw from rad to degrees
local yaw = math.deg(p) local yaw = math.deg(p)
yaw = math.floor(yaw / 90) yaw = math.floor(yaw / 90)
@@ -97,13 +97,13 @@ minetest.register_entity(
p = yaw p = yaw
--add -y force --add -y force
local force = {x = 0, y = -10, z = 0} local force = {x = 0, y = -10, z = 0}
self.object:setvelocity(force) self.object:set_velocity(force)
if self._tmr < 0.2 then if self._tmr < 0.2 then
return return
else else
self._tmr = 0 self._tmr = 0
end end
local pos = self.object:getpos() local pos = self.object:get_pos()
local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z} local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z}
local d local d
--swap 1 and 3 in p --swap 1 and 3 in p
@@ -113,7 +113,7 @@ minetest.register_entity(
p = 1 p = 1
end end
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 10)) do for i, ob in pairs(minetest.get_objects_inside_radius(pos, 10)) do
if portalgun_visiable(pos1, ob) and (ob:is_player()) then if portalgun_visible(pos1, ob) and (ob:is_player()) then
local a = ob:get_pos() local a = ob:get_pos()
if a.y < pos.y + 2 and a.y > pos.y - 1 then if a.y < pos.y + 2 and a.y > pos.y - 1 then
a = {x = math.floor(a.x), y = math.floor(a.y), z = math.floor(a.z)} a = {x = math.floor(a.x), y = math.floor(a.y), z = math.floor(a.z)}
@@ -134,11 +134,15 @@ minetest.register_entity(
end end
end end
if d then if d then
minetest.add_entity(pos1, "portalgun:bullet1"):set_velocity(d) local bullet_ent = minetest.add_entity(pos1, "portalgun:bullet1")
bullet_ent:set_velocity(d)
--rotate bullet to by 90 degrees in x axis
local yaw = math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360))
bullet_ent:set_yaw(yaw)
minetest.sound_play("portalgun_bullet1", {pos = pos, gain = 1, max_hear_distance = 15}) minetest.sound_play("portalgun_bullet1", {pos = pos, gain = 1, max_hear_distance = 15})
else else
local obj = minetest.add_entity(pos1, "portalgun:turretgun") local obj = minetest.add_entity(pos1, "portalgun:turretgun")
obj:setyaw(self.object:getyaw()) obj:set_yaw(self.object:get_yaw())
self.object:remove() self.object:remove()
end end
return true return true
@@ -189,7 +193,8 @@ minetest.register_node("portalgun:turretgun_spawner",
local objs = minetest.get_objects_inside_radius(pos2, 1) local objs = minetest.get_objects_inside_radius(pos2, 1)
local found = 0 local found = 0
for i, obj in pairs(objs) do for i, obj in pairs(objs) do
if obj:get_luaentity().name == "portalgun:turretgun" then local name = obj:get_luaentity().name
if name== "portalgun:turretgun" or name == "portalgun:turretgun2" then
found = found + 1 found = found + 1
end end
end end
@@ -197,7 +202,7 @@ minetest.register_node("portalgun:turretgun_spawner",
local obj = minetest.add_entity(pos2, "portalgun:turretgun") local obj = minetest.add_entity(pos2, "portalgun:turretgun")
obj:setyaw(math.rad(meta:get_int("yaw"))) obj:setyaw(math.rad(meta:get_int("yaw")))
end end
minetest.get_node_timer(pos1):start(10) minetest.get_node_timer(pos1):start(120)
end end
}) })
@@ -216,12 +221,12 @@ minetest.register_entity(
automatic_rotate = 0, automatic_rotate = 0,
_tmr = 0, _tmr = 0,
_stop = 1, _stop = 1,
visual_size = {x = 6, y = 6}, visual_size = {x = 5.8, y = 5.8},
mesh = "turret1.obj", mesh = "turret1.obj",
on_step = function(self, elapsed, moveresult) on_step = function(self, elapsed, moveresult)
self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360))) self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360)))
--get yaw and convert it into param2 --get yaw and convert it into param2
local p = self.object:getyaw() local p = self.object:get_yaw()
--convert yaw from rad to degrees --convert yaw from rad to degrees
local yaw = math.deg(p) local yaw = math.deg(p)
yaw = math.floor(yaw / 90) yaw = math.floor(yaw / 90)
@@ -233,7 +238,7 @@ minetest.register_entity(
local pos = self.object:get_pos() local pos = self.object:get_pos()
local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z} local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z}
local force = {x = 0, y = -10, z = 0} local force = {x = 0, y = -10, z = 0}
self.object:setvelocity(force) self.object:set_velocity(force)
self._tmr = self._tmr + elapsed self._tmr = self._tmr + elapsed
if self._tmr < 0.2 then if self._tmr < 0.2 then
return return
@@ -249,7 +254,7 @@ minetest.register_entity(
local d local d
for i, ob in pairs(minetest.get_objects_inside_radius(pos1, 10)) do for i, ob in pairs(minetest.get_objects_inside_radius(pos1, 10)) do
if portalgun_visiable(pos1, ob) and (ob:is_player()) then if portalgun_visible(pos1, ob) and (ob:is_player()) then
local a = ob:get_pos() local a = ob:get_pos()
if a.y < pos.y + 2 and a.y > pos.y - 1 then if a.y < pos.y + 2 and a.y > pos.y - 1 then
a = {x = math.floor(a.x), y = math.floor(a.y), z = math.floor(a.z)} a = {x = math.floor(a.x), y = math.floor(a.y), z = math.floor(a.z)}
@@ -273,7 +278,7 @@ minetest.register_entity(
if d then if d then
local obj = minetest.add_entity(pos1, "portalgun:turretgun2") local obj = minetest.add_entity(pos1, "portalgun:turretgun2")
--set yaw to same as this object --set yaw to same as this object
obj:setyaw(self.object:getyaw()) obj:setyaw(self.object:get_yaw())
self.object:remove() self.object:remove()
end end
return true return true
@@ -281,7 +286,7 @@ minetest.register_entity(
} }
) )
function portalgun_visiable(pos, ob) function portalgun_visible(pos, ob)
if ob == nil or ob:get_pos() == nil or ob:get_pos().y == nil then if ob == nil or ob:get_pos() == nil or ob:get_pos().y == nil then
return false return false
end end
@@ -320,6 +325,7 @@ minetest.register_entity(
--collisionbox={-0.01,-0.01,-0.01,0.01,0.01,0.01}, --collisionbox={-0.01,-0.01,-0.01,0.01,0.01,0.01},
pointable = false, pointable = false,
visual = "mesh", visual = "mesh",
visual_size = {x = 2, y = 2},
mesh = "bullet.obj", mesh = "bullet.obj",
--yellow color as tiles --yellow color as tiles
tiles = {"#color[yellow]"}, tiles = {"#color[yellow]"},

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB