Added planned_things file
|
@ -0,0 +1,47 @@
|
|||
--EFFECTS--
|
||||
function medicine.register_effect_type(effect_type_id, description, icon, groups, apply, cancel, hidden, cancel_on_death, repeat_interval)
|
||||
local effect_type = {}
|
||||
effect_type.description = description
|
||||
effect_type.apply = apply
|
||||
effect_type.groups = groups
|
||||
effect_type.icon = icon
|
||||
if cancel ~= nil then
|
||||
effect_type.cancel = cancel
|
||||
else
|
||||
effect_type.cancel = function() end
|
||||
end
|
||||
if hidden ~= nil then
|
||||
effect_type.hidden = hidden
|
||||
else
|
||||
effect_type.hidden = false
|
||||
end
|
||||
if cancel_on_death ~= nil then
|
||||
effect_type.cancel_on_death = cancel_on_death
|
||||
else
|
||||
effect_type.cancel_on_death = true
|
||||
end
|
||||
effect_type.repeat_interval = repeat_interval
|
||||
|
||||
playereffects.effect_types[effect_type_id] = effect_type
|
||||
minetest.log("action", "[medicine] Effect type "..effect_type_id.." registered!")
|
||||
end
|
||||
|
||||
medicine.register_effect_type("poisoning", "Poisoning", nil, {},
|
||||
function(player)
|
||||
local hudid = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = { x=0.5, y=0.5 },
|
||||
scale = { x=-100, y=-100 },
|
||||
text = "poisonous_heart.png",
|
||||
})
|
||||
if(hudid ~= nil) then
|
||||
return { hudid = hudid }
|
||||
else
|
||||
minetest.log("error", "[medicine] [examples] The effect \"Poisoning\" could not be applied. The call to hud_add(...) failed.")
|
||||
return false
|
||||
end
|
||||
end,
|
||||
function(effect, player)
|
||||
player:hud_remove(effect.metadata.hudid)
|
||||
end
|
||||
)
|
|
@ -0,0 +1,133 @@
|
|||
SLIME_SIZE = 0.5
|
||||
SLIME_BOX = math.sqrt(2*math.pow(SLIME_SIZE, 2))/2
|
||||
GRAVITY = 9.8
|
||||
|
||||
minetest.register_entity("medicine:small",{
|
||||
initial_properties = {
|
||||
hp_max = 15,
|
||||
visual_size = {x = SLIME_SIZE, y = SLIME_SIZE, z = SLIME_SIZE},
|
||||
visual = "cube",
|
||||
textures = {
|
||||
"medicine_cube_top.png",
|
||||
"medicine_cube_bottom.png",
|
||||
"medicine_cube_front.png",
|
||||
"medicine_cube_side1.png",
|
||||
"medicine_cube_side2.png",
|
||||
"medicine_cube_back.png",
|
||||
},
|
||||
collisionbox = {-SLIME_BOX, -SLIME_SIZE/2, -SLIME_BOX, SLIME_BOX, SLIME_SIZE/2, SLIME_BOX},
|
||||
physical = true,
|
||||
},
|
||||
|
||||
timer = 100000,
|
||||
timer2 = 100000,
|
||||
timer3 = 100000, --regularly check if slime touches ground and possibly set x/z velocity/acceleration to 0
|
||||
yaw = 0,
|
||||
direction = {},
|
||||
status = 2, --1 = jump, 2 = rotate
|
||||
attracts_slime = true,
|
||||
found_friend = false,
|
||||
|
||||
on_activate = function(self)
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end,
|
||||
|
||||
on_rightclick = function(self)
|
||||
if self.object:get_hp() <= 0 then
|
||||
minetest.env:add_item(self.object:getpos(), "medicine:filling_syringe", "medicine:cotton_wool", "medicine:alcohol", "medicine:plaster")
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.timer2 = self.timer2 + dtime
|
||||
if self.status == 2 and (self.timer2 >= 0.5) then
|
||||
self.timer2 = 1.2
|
||||
self.status = 1
|
||||
|
||||
local pos = self.object:getpos()
|
||||
if slime_lonely(pos) and not minetest.env:find_node_near(pos, 16, "farming:apple") then
|
||||
self.object:remove()
|
||||
end
|
||||
self.yaw = slime_getyaw(pos)
|
||||
if self.yaw == false then
|
||||
self.yaw = math.random() * 360
|
||||
self.found_friend = false
|
||||
else
|
||||
self.found_friend = true
|
||||
end
|
||||
self.object:setyaw(self.yaw)
|
||||
self.object:set_properties({automatic_rotate = 0})
|
||||
self.direction = {x = math.cos(self.yaw)*2, y = 6, z = math.sin(self.yaw)*2}
|
||||
end
|
||||
|
||||
|
||||
self.timer = self.timer + dtime
|
||||
self.timer3 = self.timer3 + dtime
|
||||
|
||||
if self.timer2 > 1.3 and self.object:getvelocity().y == 0 then
|
||||
self.object:setvelocity(self.direction)
|
||||
self.object:setacceleration({x = self.direction.x/5, y = -GRAVITY, z = self.direction.z/5})
|
||||
self.timer2 = 0
|
||||
end
|
||||
|
||||
if (self.timer >= 6 or (self.timer >= 1 and self.found_friend == true)) and self.object:getvelocity().y == 0 then
|
||||
self.timer = 0
|
||||
self.timer2 = 0
|
||||
|
||||
self.status = 2
|
||||
if not self.found_friend then
|
||||
self.object:set_properties({automatic_rotate = math.pi * 8})
|
||||
end
|
||||
end
|
||||
|
||||
if self.timer3 > 0.07 then
|
||||
vel = self.object:getvelocity()
|
||||
if vel.y == 0 and (vel.x ~= 0 or vel.z ~= 0) then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end
|
||||
self.timer3 = 0
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function slime_lonely (pos)
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 32)
|
||||
for i, obj in pairs(objs) do
|
||||
if obj:is_player() then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function approx(val1, val2, deviation)
|
||||
if val1 + deviation > val2
|
||||
and val1 - deviation < val2 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function slime_getyaw (pos) -- get yaw, only if objects to follow nearby
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 7)
|
||||
for i, obj in ipairs(objs) do
|
||||
if obj:is_player() or obj:get_luaentity().name == "medicine:small" then
|
||||
local ppos = {x = obj:getpos().x - pos.x,
|
||||
z = obj:getpos().z - pos.z}
|
||||
if ppos.x ~= 0 and ppos.z ~= 0 then --found itself as an object
|
||||
local yaw = math.abs(math.atan(ppos.x/ppos.z) - math.pi / 2)
|
||||
if ppos.z < 0 then yaw = yaw + math.pi end
|
||||
return yaw
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"medicine:medicine_block"},
|
||||
interval = 10.0,
|
||||
chance = 100000,
|
||||
action = function(pos, node)
|
||||
minetest.env:add_entity({x=pos.x, y=pos.y + 1, z=pos.z}, "slimes:small")
|
||||
end,
|
||||
})
|
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 174 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 234 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 593 B |