disable mobs and slime, update bags
@ -1,25 +1,34 @@
|
|||||||
local old_nodes = {"flowers:flower_seaweed"}
|
local old_nodes = {"flowers:flower_seaweed"}
|
||||||
local old_entities = {}
|
local old_entities = {
|
||||||
|
"mobs:dirt_monster",
|
||||||
for _,node_name in ipairs(old_nodes) do
|
"mobs:stone_monster",
|
||||||
minetest.register_node(":"..node_name, {
|
"mobs:sand_monster",
|
||||||
groups = {old=1},
|
"mobs:sheep",
|
||||||
})
|
"mobs:meat_raw",
|
||||||
end
|
"mobs:meat_rat",
|
||||||
|
"mobs:oerkki",
|
||||||
minetest.register_abm({
|
"slimes:small",
|
||||||
nodenames = {"group:old"},
|
}
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
for _,node_name in ipairs(old_nodes) do
|
||||||
action = function(pos, node)
|
minetest.register_node(":"..node_name, {
|
||||||
minetest.env:remove_node(pos)
|
groups = {old=1},
|
||||||
end,
|
})
|
||||||
})
|
end
|
||||||
|
|
||||||
for _,entity_name in ipairs(old_entities) do
|
minetest.register_abm({
|
||||||
minetest.register_entity(":"..entity_name, {
|
nodenames = {"group:old"},
|
||||||
on_activate = function(self, staticdata)
|
interval = 1,
|
||||||
self.object:remove()
|
chance = 1,
|
||||||
end,
|
action = function(pos, node)
|
||||||
})
|
minetest.env:remove_node(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
for _,entity_name in ipairs(old_entities) do
|
||||||
|
minetest.register_entity(":"..entity_name, {
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.object:remove()
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
0
mods/_disabled/init.lua
Normal file
@ -1,98 +1,98 @@
|
|||||||
=== MOBS-MOD for MINETEST-C55 ===
|
=== MOBS-MOD for MINETEST-C55 ===
|
||||||
by PilzAdam
|
by PilzAdam
|
||||||
|
|
||||||
Inroduction:
|
Inroduction:
|
||||||
This mod adds some basic hostile and friendly mobs to the game.
|
This mod adds some basic hostile and friendly mobs to the game.
|
||||||
|
|
||||||
How to install:
|
How to install:
|
||||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||||
if you have a windows client or a linux run-in-place client. If you have
|
if you have a windows client or a linux run-in-place client. If you have
|
||||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||||
If you want to install this mod only in one world create the folder
|
If you want to install this mod only in one world create the folder
|
||||||
worldmods/ in your worlddirectory.
|
worldmods/ in your worlddirectory.
|
||||||
For further information or help see:
|
For further information or help see:
|
||||||
http://wiki.minetest.com/wiki/Installing_Mods
|
http://wiki.minetest.com/wiki/Installing_Mods
|
||||||
|
|
||||||
How to use the mod:
|
How to use the mod:
|
||||||
There are 4 hostile mobs that want to kill the player:
|
There are 4 hostile mobs that want to kill the player:
|
||||||
- The dirt monster spawns at night on grass and get killed on day when
|
- The dirt monster spawns at night on grass and get killed on day when
|
||||||
its too light.
|
its too light.
|
||||||
- The stone monster spawns on stone and is stronger but slower than the
|
- The stone monster spawns on stone and is stronger but slower than the
|
||||||
dirt monster
|
dirt monster
|
||||||
- The desert monster spawns in deserts and is faster but less strong
|
- The desert monster spawns in deserts and is faster but less strong
|
||||||
than the dirt monster
|
than the dirt monster
|
||||||
- The oerkki is the same as in 0.3. It spawns in realy dark caves and
|
- The oerkki is the same as in 0.3. It spawns in realy dark caves and
|
||||||
is stronger than the dirt monster.
|
is stronger than the dirt monster.
|
||||||
There are also 2 friendly mobs:
|
There are also 2 friendly mobs:
|
||||||
- The sheep spawns on grass. You can get wool from it when you rightclick
|
- The sheep spawns on grass. You can get wool from it when you rightclick
|
||||||
it and meat if you kill it. Meat can bee cooked in the furnace to eat it.
|
it and meat if you kill it. Meat can bee cooked in the furnace to eat it.
|
||||||
- The rat is the same as in 0.3. You can cook it or replace it in the
|
- The rat is the same as in 0.3. You can cook it or replace it in the
|
||||||
world if you catched it with an rightclick.
|
world if you catched it with an rightclick.
|
||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
This mod add some functions that you can use in other mods:
|
This mod add some functions that you can use in other mods:
|
||||||
1. mobs:register_monster(name, def)
|
1. mobs:register_monster(name, def)
|
||||||
This adds a monster to Minetest that will attack the player
|
This adds a monster to Minetest that will attack the player
|
||||||
"name" is the name of the monster ("[modname]:[monstername]")
|
"name" is the name of the monster ("[modname]:[monstername]")
|
||||||
"def" is a table with the following values:
|
"def" is a table with the following values:
|
||||||
hp_max: same is in minetest.register_entity()
|
hp_max: same is in minetest.register_entity()
|
||||||
physical: same is in minetest.register_entity()
|
physical: same is in minetest.register_entity()
|
||||||
collisionbox: same is in minetest.register_entity()
|
collisionbox: same is in minetest.register_entity()
|
||||||
visual: same is in minetest.register_entity()
|
visual: same is in minetest.register_entity()
|
||||||
visual_size: same is in minetest.register_entity()
|
visual_size: same is in minetest.register_entity()
|
||||||
textures: same is in minetest.register_entity()
|
textures: same is in minetest.register_entity()
|
||||||
makes_footstep_sound: same is in minetest.register_entity()
|
makes_footstep_sound: same is in minetest.register_entity()
|
||||||
view_range: the range in that the monster will see the player
|
view_range: the range in that the monster will see the player
|
||||||
and follow him
|
and follow him
|
||||||
walk_velocity: the velocity when the monster is walking around
|
walk_velocity: the velocity when the monster is walking around
|
||||||
run_velocity: the velocity when the monster is attacking a player
|
run_velocity: the velocity when the monster is attacking a player
|
||||||
damage: the damage per second
|
damage: the damage per second
|
||||||
light_resistant: light wont cause damage on day
|
light_resistant: light wont cause damage on day
|
||||||
drop: the drop item of the monster
|
drop: the drop item of the monster
|
||||||
drop_count: the number of items that are dropped
|
drop_count: the number of items that are dropped
|
||||||
armor: the armor (integer)(3=lowest; 1=highest)(fleshy group is used)
|
armor: the armor (integer)(3=lowest; 1=highest)(fleshy group is used)
|
||||||
drawtype: "front" or "side"
|
drawtype: "front" or "side"
|
||||||
water_damage: the damage per second if the mob is in water
|
water_damage: the damage per second if the mob is in water
|
||||||
lava_damage: the damage per second if the mob is in lava
|
lava_damage: the damage per second if the mob is in lava
|
||||||
2. mobs:register_animal(name, def)
|
2. mobs:register_animal(name, def)
|
||||||
This adds a animal to Minetest that will just walk arround
|
This adds a animal to Minetest that will just walk arround
|
||||||
"name" is the name of the monster ("[modname]:[animalname]")
|
"name" is the name of the monster ("[modname]:[animalname]")
|
||||||
"def" is the same table as in register_monster but without these values:
|
"def" is the same table as in register_monster but without these values:
|
||||||
-view_range
|
-view_range
|
||||||
-run_velocity
|
-run_velocity
|
||||||
-damage
|
-damage
|
||||||
-light_resistant
|
-light_resistant
|
||||||
-armor
|
-armor
|
||||||
and it also has the field
|
and it also has the field
|
||||||
-on_rightclick: its same as in minetest.register_entity()
|
-on_rightclick: its same as in minetest.register_entity()
|
||||||
3. mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
3. mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||||
This function adds the spawning of an animal (without it the
|
This function adds the spawning of an animal (without it the
|
||||||
registered animals and monster won't spawn!)
|
registered animals and monster won't spawn!)
|
||||||
"name" is the name of the animal/monster
|
"name" is the name of the animal/monster
|
||||||
"nodes" is a list of nodenames on that the animal/monster can spawn
|
"nodes" is a list of nodenames on that the animal/monster can spawn
|
||||||
"max_light" is the maximum of light
|
"max_light" is the maximum of light
|
||||||
"min_light" is the minimum of light
|
"min_light" is the minimum of light
|
||||||
"chance" is same as in register_abm()
|
"chance" is same as in register_abm()
|
||||||
"mobs_per_30_block_radius" is the maximum number of mobs in a 30 block
|
"mobs_per_30_block_radius" is the maximum number of mobs in a 30 block
|
||||||
radius arround the possible spawning pos
|
radius arround the possible spawning pos
|
||||||
|
|
||||||
License:
|
License:
|
||||||
Sourcecode: WTFPL (see below)
|
Sourcecode: WTFPL (see below)
|
||||||
Grahpics: WTFPL (see below)
|
Grahpics: WTFPL (see below)
|
||||||
|
|
||||||
See also:
|
See also:
|
||||||
http://minetest.net/
|
http://minetest.net/
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
Version 2, December 2004
|
Version 2, December 2004
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Everyone is permitted to copy and distribute verbatim or modified
|
||||||
copies of this license document, and changing it is allowed as long
|
copies of this license document, and changing it is allowed as long
|
||||||
as the name is changed.
|
as the name is changed.
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
@ -1,457 +1,457 @@
|
|||||||
mobs = {}
|
mobs = {}
|
||||||
function mobs:register_monster(name, def)
|
function mobs:register_monster(name, def)
|
||||||
minetest.register_entity(name, {
|
minetest.register_entity(name, {
|
||||||
hp_max = def.hp_max,
|
hp_max = def.hp_max,
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = def.collisionbox,
|
collisionbox = def.collisionbox,
|
||||||
visual = def.visual,
|
visual = def.visual,
|
||||||
visual_size = def.visual_size,
|
visual_size = def.visual_size,
|
||||||
textures = def.textures,
|
textures = def.textures,
|
||||||
makes_footstep_sound = def.makes_footstep_sound,
|
makes_footstep_sound = def.makes_footstep_sound,
|
||||||
view_range = def.view_range,
|
view_range = def.view_range,
|
||||||
walk_velocity = def.walk_velocity,
|
walk_velocity = def.walk_velocity,
|
||||||
run_velocity = def.run_velocity,
|
run_velocity = def.run_velocity,
|
||||||
damage = def.damage,
|
damage = def.damage,
|
||||||
light_resistant = def.light_resistant,
|
light_resistant = def.light_resistant,
|
||||||
water_damage = def.water_damage,
|
water_damage = def.water_damage,
|
||||||
lava_damage = def.lava_damage,
|
lava_damage = def.lava_damage,
|
||||||
drop = def.drop,
|
drop = def.drop,
|
||||||
drop_count = def.drop_count,
|
drop_count = def.drop_count,
|
||||||
armor = def.armor,
|
armor = def.armor,
|
||||||
drawtype = def.drawtype,
|
drawtype = def.drawtype,
|
||||||
|
|
||||||
timer = 0,
|
timer = 0,
|
||||||
attack = {player=nil, dist=nil},
|
attack = {player=nil, dist=nil},
|
||||||
state = "stand",
|
state = "stand",
|
||||||
v_start = false,
|
v_start = false,
|
||||||
old_y = nil,
|
old_y = nil,
|
||||||
|
|
||||||
|
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
if self.drawtype == "side" then
|
if self.drawtype == "side" then
|
||||||
yaw = yaw+(math.pi/2)
|
yaw = yaw+(math.pi/2)
|
||||||
end
|
end
|
||||||
local x = math.sin(yaw) * -v
|
local x = math.sin(yaw) * -v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_velocity = function(self)
|
get_velocity = function(self)
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
return (v.x^2 + v.z^2)^(0.5)
|
return (v.x^2 + v.z^2)^(0.5)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.object:getvelocity().y > 0.1 then
|
if self.object:getvelocity().y > 0.1 then
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
if self.drawtype == "side" then
|
if self.drawtype == "side" then
|
||||||
yaw = yaw+(math.pi/2)
|
yaw = yaw+(math.pi/2)
|
||||||
end
|
end
|
||||||
local x = math.sin(yaw) * -2
|
local x = math.sin(yaw) * -2
|
||||||
local z = math.cos(yaw) * 2
|
local z = math.cos(yaw) * 2
|
||||||
self.object:setacceleration({x=x, y=-10, z=z})
|
self.object:setacceleration({x=x, y=-10, z=z})
|
||||||
else
|
else
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.object:getvelocity().y == 0 then
|
if self.object:getvelocity().y == 0 then
|
||||||
if not self.old_y then
|
if not self.old_y then
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
else
|
else
|
||||||
local d = self.old_y - self.object:getpos().y
|
local d = self.old_y - self.object:getpos().y
|
||||||
if d > 5 then
|
if d > 5 then
|
||||||
local damage = d-5
|
local damage = d-5
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[self.armor]=1/damage}},
|
fleshy={times={[self.armor]=1/damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.timer = self.timer+dtime
|
self.timer = self.timer+dtime
|
||||||
if self.state ~= "attack" then
|
if self.state ~= "attack" then
|
||||||
if self.timer < 1 then
|
if self.timer < 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local do_env_damage = function(self)
|
local do_env_damage = function(self)
|
||||||
if not self.light_resistant and minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 and minetest.env:get_node_light(self.object:getpos()) > 3 then
|
if not self.light_resistant and minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 and minetest.env:get_node_light(self.object:getpos()) > 3 then
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[self.armor]=1/1}},
|
fleshy={times={[self.armor]=1/1}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[self.armor]=1/self.water_damage}},
|
fleshy={times={[self.armor]=1/self.water_damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[self.armor]=1/self.lava_damage}},
|
fleshy={times={[self.armor]=1/self.lava_damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "attack" and self.timer > 1 then
|
if self.state == "attack" and self.timer > 1 then
|
||||||
do_env_damage(self)
|
do_env_damage(self)
|
||||||
elseif self.state ~= "attack" then
|
elseif self.state ~= "attack" then
|
||||||
do_env_damage(self)
|
do_env_damage(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
local p = player:getpos()
|
local p = player:getpos()
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||||
if dist < self.view_range then
|
if dist < self.view_range then
|
||||||
if self.attack.dist then
|
if self.attack.dist then
|
||||||
if self.attack.dist < dist then
|
if self.attack.dist < dist then
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
self.attack.player = player
|
self.attack.player = player
|
||||||
self.attack.dist = dist
|
self.attack.dist = dist
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
self.attack.player = player
|
self.attack.player = player
|
||||||
self.attack.dist = dist
|
self.attack.dist = dist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == "stand" then
|
||||||
if math.random(1, 2) == 1 then
|
if math.random(1, 2) == 1 then
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||||
end
|
end
|
||||||
if math.random(1, 100) <= 50 then
|
if math.random(1, 100) <= 50 then
|
||||||
self.set_velocity(self, self.walk_velocity)
|
self.set_velocity(self, self.walk_velocity)
|
||||||
self.state = "walk"
|
self.state = "walk"
|
||||||
end
|
end
|
||||||
elseif self.state == "walk" then
|
elseif self.state == "walk" then
|
||||||
if math.random(1, 100) <= 30 then
|
if math.random(1, 100) <= 30 then
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||||
self.set_velocity(self, self.get_velocity(self))
|
self.set_velocity(self, self.get_velocity(self))
|
||||||
end
|
end
|
||||||
if math.random(1, 100) <= 10 then
|
if math.random(1, 100) <= 10 then
|
||||||
self.set_velocity(self, 0)
|
self.set_velocity(self, 0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
end
|
end
|
||||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
v.y = 5
|
v.y = 5
|
||||||
self.object:setvelocity(v)
|
self.object:setvelocity(v)
|
||||||
end
|
end
|
||||||
elseif self.state == "attack" then
|
elseif self.state == "attack" then
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
local p = self.attack.player:getpos()
|
local p = self.attack.player:getpos()
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||||
if dist > self.view_range or self.attack.player:get_hp() <= 0 then
|
if dist > self.view_range or self.attack.player:get_hp() <= 0 then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
self.set_velocity(self, 0)
|
self.set_velocity(self, 0)
|
||||||
self.attack = {player=nil, dist=nil}
|
self.attack = {player=nil, dist=nil}
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
self.attack.dist = dist
|
self.attack.dist = dist
|
||||||
end
|
end
|
||||||
|
|
||||||
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
||||||
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
||||||
if self.drawtype == "side" then
|
if self.drawtype == "side" then
|
||||||
yaw = yaw+(math.pi/2)
|
yaw = yaw+(math.pi/2)
|
||||||
end
|
end
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
self.object:setyaw(yaw)
|
self.object:setyaw(yaw)
|
||||||
if self.attack.dist > 2 then
|
if self.attack.dist > 2 then
|
||||||
if not self.v_start then
|
if not self.v_start then
|
||||||
self.v_start = true
|
self.v_start = true
|
||||||
self.set_velocity(self, self.run_velocity)
|
self.set_velocity(self, self.run_velocity)
|
||||||
else
|
else
|
||||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
v.y = 5
|
v.y = 5
|
||||||
self.object:setvelocity(v)
|
self.object:setvelocity(v)
|
||||||
end
|
end
|
||||||
self.set_velocity(self, self.run_velocity)
|
self.set_velocity(self, self.run_velocity)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.set_velocity(self, 0)
|
self.set_velocity(self, 0)
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
if self.timer > 1 then
|
if self.timer > 1 then
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
local d1 = 10
|
local d1 = 10
|
||||||
local d2 = 10
|
local d2 = 10
|
||||||
local d3 = 10
|
local d3 = 10
|
||||||
if self.damage > 0 then
|
if self.damage > 0 then
|
||||||
d3 = 1/self.damage
|
d3 = 1/self.damage
|
||||||
end
|
end
|
||||||
if self.damage > 1 then
|
if self.damage > 1 then
|
||||||
d2 = 1/(self.damage-1)
|
d2 = 1/(self.damage-1)
|
||||||
end
|
end
|
||||||
if self.damage > 2 then
|
if self.damage > 2 then
|
||||||
d1 = 1/(self.damage-2)
|
d1 = 1/(self.damage-2)
|
||||||
end
|
end
|
||||||
self.attack.player:punch(self.object, 1.0, {
|
self.attack.player:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[1]=d1, [2]=d2, [3]=d3}},
|
fleshy={times={[1]=d1, [2]=d2, [3]=d3}},
|
||||||
}
|
}
|
||||||
}, vec)
|
}, vec)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
self.object:set_armor_groups({fleshy=self.armor})
|
self.object:set_armor_groups({fleshy=self.armor})
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
if self.object:get_hp() <= 0 then
|
if self.object:get_hp() <= 0 then
|
||||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for i=1,math.random(0,2)-1+self.drop_count do
|
||||||
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for i=1,math.random(0,2)-1+self.drop_count do
|
||||||
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
||||||
if obj then
|
if obj then
|
||||||
obj:get_luaentity().collect = true
|
obj:get_luaentity().collect = true
|
||||||
local x = math.random(1, 5)
|
local x = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
x = -x
|
x = -x
|
||||||
end
|
end
|
||||||
local z = math.random(1, 5)
|
local z = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
z = -z
|
z = -z
|
||||||
end
|
end
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function mobs:register_animal(name, def)
|
function mobs:register_animal(name, def)
|
||||||
minetest.register_entity(name, {
|
minetest.register_entity(name, {
|
||||||
hp_max = def.hp_max,
|
hp_max = def.hp_max,
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = def.collisionbox,
|
collisionbox = def.collisionbox,
|
||||||
visual = def.visual,
|
visual = def.visual,
|
||||||
visual_size = def.visual_size,
|
visual_size = def.visual_size,
|
||||||
textures = def.textures,
|
textures = def.textures,
|
||||||
makes_footstep_sound = def.makes_footstep_sound,
|
makes_footstep_sound = def.makes_footstep_sound,
|
||||||
walk_velocity = def.walk_velocity,
|
walk_velocity = def.walk_velocity,
|
||||||
drop = def.drop,
|
drop = def.drop,
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
drop_count = def.drop_count,
|
drop_count = def.drop_count,
|
||||||
drawtype = def.drawtype,
|
drawtype = def.drawtype,
|
||||||
water_damage = def.water_damage,
|
water_damage = def.water_damage,
|
||||||
lava_damage = def.lava_damage,
|
lava_damage = def.lava_damage,
|
||||||
|
|
||||||
timer = 0,
|
timer = 0,
|
||||||
state = "stand",
|
state = "stand",
|
||||||
old_y = nil,
|
old_y = nil,
|
||||||
|
|
||||||
|
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
if self.drawtype == "side" then
|
if self.drawtype == "side" then
|
||||||
yaw = yaw+(math.pi/2)
|
yaw = yaw+(math.pi/2)
|
||||||
end
|
end
|
||||||
local x = math.sin(yaw) * -v
|
local x = math.sin(yaw) * -v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_velocity = function(self)
|
get_velocity = function(self)
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
return (v.x^2 + v.z^2)^(0.5)
|
return (v.x^2 + v.z^2)^(0.5)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.object:getvelocity().y > 0.1 then
|
if self.object:getvelocity().y > 0.1 then
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
if self.drawtype == "side" then
|
if self.drawtype == "side" then
|
||||||
yaw = yaw+(math.pi/2)
|
yaw = yaw+(math.pi/2)
|
||||||
end
|
end
|
||||||
local x = math.sin(yaw) * -2
|
local x = math.sin(yaw) * -2
|
||||||
local z = math.cos(yaw) * 2
|
local z = math.cos(yaw) * 2
|
||||||
self.object:setacceleration({x=x, y=-10, z=z})
|
self.object:setacceleration({x=x, y=-10, z=z})
|
||||||
else
|
else
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.object:getvelocity().y == 0 then
|
if self.object:getvelocity().y == 0 then
|
||||||
if not self.old_y then
|
if not self.old_y then
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
else
|
else
|
||||||
local d = self.old_y - self.object:getpos().y
|
local d = self.old_y - self.object:getpos().y
|
||||||
if d > 5 then
|
if d > 5 then
|
||||||
local damage = d-5
|
local damage = d-5
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[3]=1/damage}},
|
fleshy={times={[3]=1/damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.timer = self.timer+dtime
|
self.timer = self.timer+dtime
|
||||||
if self.timer < 1 then
|
if self.timer < 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
|
||||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[3]=1/self.water_damage}},
|
fleshy={times={[3]=1/self.water_damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||||
self.object:punch(self.object, 1.0, {
|
self.object:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
fleshy={times={[3]=1/self.lava_damage}},
|
fleshy={times={[3]=1/self.lava_damage}},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == "stand" then
|
||||||
if math.random(1, 2) == 1 then
|
if math.random(1, 2) == 1 then
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||||
end
|
end
|
||||||
if math.random(1, 100) <= 50 then
|
if math.random(1, 100) <= 50 then
|
||||||
self.set_velocity(self, self.walk_velocity)
|
self.set_velocity(self, self.walk_velocity)
|
||||||
self.state = "walk"
|
self.state = "walk"
|
||||||
end
|
end
|
||||||
elseif self.state == "walk" then
|
elseif self.state == "walk" then
|
||||||
if math.random(1, 100) <= 30 then
|
if math.random(1, 100) <= 30 then
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||||
self.set_velocity(self, self.get_velocity(self))
|
self.set_velocity(self, self.get_velocity(self))
|
||||||
end
|
end
|
||||||
if math.random(1, 100) <= 10 then
|
if math.random(1, 100) <= 10 then
|
||||||
self.set_velocity(self, 0)
|
self.set_velocity(self, 0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
end
|
end
|
||||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
v.y = 5
|
v.y = 5
|
||||||
self.object:setvelocity(v)
|
self.object:setvelocity(v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
self.object:set_armor_groups({fleshy=3})
|
self.object:set_armor_groups({fleshy=3})
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
if self.object:get_hp() <= 0 then
|
if self.object:get_hp() <= 0 then
|
||||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for i=1,math.random(0,2)-1+self.drop_count do
|
||||||
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for i=1,math.random(0,2)-1+self.drop_count do
|
||||||
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
||||||
if obj then
|
if obj then
|
||||||
obj:get_luaentity().collect = true
|
obj:get_luaentity().collect = true
|
||||||
local x = math.random(1, 5)
|
local x = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
x = -x
|
x = -x
|
||||||
end
|
end
|
||||||
local z = math.random(1, 5)
|
local z = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
z = -z
|
z = -z
|
||||||
end
|
end
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = nodes,
|
nodenames = nodes,
|
||||||
neighbors = nodes,
|
neighbors = nodes,
|
||||||
interval = 30,
|
interval = 30,
|
||||||
chance = chance,
|
chance = chance,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if not minetest.env:get_node_light(pos) then
|
if not minetest.env:get_node_light(pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node_light(pos) > max_light then
|
if minetest.env:get_node_light(pos) > max_light then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node_light(pos) < min_light then
|
if minetest.env:get_node_light(pos) < min_light then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node(pos).name ~= "air" then
|
if minetest.env:get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if minetest.env:get_node(pos).name ~= "air" then
|
if minetest.env:get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
return
|
return
|
||||||
elseif obj:get_luaentity().name == name then
|
elseif obj:get_luaentity().name == name then
|
||||||
count = count+1
|
count = count+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if count > mobs_per_30_block_radius then
|
if count > mobs_per_30_block_radius then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.setting_getbool("display_mob_spawn") then
|
if minetest.setting_getbool("display_mob_spawn") then
|
||||||
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
minetest.env:add_entity(pos, name)
|
minetest.env:add_entity(pos, name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
@ -1 +1 @@
|
|||||||
default
|
default
|
@ -1,182 +1,182 @@
|
|||||||
dofile(minetest.get_modpath("mobs").."/api.lua")
|
dofile(minetest.get_modpath("mobs").."/api.lua")
|
||||||
|
|
||||||
mobs:register_monster("mobs:dirt_monster", {
|
mobs:register_monster("mobs:dirt_monster", {
|
||||||
hp_max = 5,
|
hp_max = 5,
|
||||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=1, y=2},
|
visual_size = {x=1, y=2},
|
||||||
textures = {"mobs_dirt_monster.png", "mobs_dirt_monster_back.png"},
|
textures = {"mobs_dirt_monster.png", "mobs_dirt_monster_back.png"},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
view_range = 15,
|
view_range = 15,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
damage = 2,
|
damage = 2,
|
||||||
drop = "default:dirt",
|
drop = "default:dirt",
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 5)
|
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 5)
|
||||||
|
|
||||||
mobs:register_monster("mobs:stone_monster", {
|
mobs:register_monster("mobs:stone_monster", {
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=1, y=2},
|
visual_size = {x=1, y=2},
|
||||||
textures = {"mobs_stone_monster.png", "mobs_stone_monster_back.png"},
|
textures = {"mobs_stone_monster.png", "mobs_stone_monster_back.png"},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
view_range = 10,
|
view_range = 10,
|
||||||
walk_velocity = 0.5,
|
walk_velocity = 0.5,
|
||||||
run_velocity = 2,
|
run_velocity = 2,
|
||||||
damage = 3,
|
damage = 3,
|
||||||
drop = "default:mossycobble",
|
drop = "default:mossycobble",
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 2,
|
armor = 2,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 0,
|
lava_damage = 0,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 5000, 5)
|
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 5000, 5)
|
||||||
|
|
||||||
|
|
||||||
mobs:register_monster("mobs:sand_monster", {
|
mobs:register_monster("mobs:sand_monster", {
|
||||||
hp_max = 3,
|
hp_max = 3,
|
||||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=1, y=2},
|
visual_size = {x=1, y=2},
|
||||||
textures = {"mobs_sand_monster.png", "mobs_sand_monster_back.png"},
|
textures = {"mobs_sand_monster.png", "mobs_sand_monster_back.png"},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
view_range = 15,
|
view_range = 15,
|
||||||
walk_velocity = 1.5,
|
walk_velocity = 1.5,
|
||||||
run_velocity = 4,
|
run_velocity = 4,
|
||||||
damage = 1,
|
damage = 1,
|
||||||
drop = "default:sand",
|
drop = "default:sand",
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
water_damage = 3,
|
water_damage = 3,
|
||||||
lava_damage = 1,
|
lava_damage = 1,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 5000, 5)
|
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 5000, 5)
|
||||||
|
|
||||||
mobs:register_animal("mobs:sheep", {
|
mobs:register_animal("mobs:sheep", {
|
||||||
hp_max = 5,
|
hp_max = 5,
|
||||||
collisionbox = {-0.6, -0.625, -0.6, 0.6, 0.625, 0.6},
|
collisionbox = {-0.6, -0.625, -0.6, 0.6, 0.625, 0.6},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=2, y=1.25},
|
visual_size = {x=2, y=1.25},
|
||||||
textures = {"mobs_sheep.png", "mobs_sheep.png"},
|
textures = {"mobs_sheep.png", "mobs_sheep.png"},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
drop = "mobs:meat_raw",
|
drop = "mobs:meat_raw",
|
||||||
drop_count = 2,
|
drop_count = 2,
|
||||||
drawtype = "side",
|
drawtype = "side",
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if self.naked then
|
if self.naked then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if clicker:get_inventory() then
|
if clicker:get_inventory() then
|
||||||
self.naked = true,
|
self.naked = true,
|
||||||
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
|
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
textures = {"mobs_sheep_naked.png", "mobs_sheep_naked.png"},
|
textures = {"mobs_sheep_naked.png", "mobs_sheep_naked.png"},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 8000, 1)
|
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 8000, 1)
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:meat_raw", {
|
minetest.register_craftitem("mobs:meat_raw", {
|
||||||
description = "Raw Meat",
|
description = "Raw Meat",
|
||||||
inventory_image = "mobs_meat_raw.png",
|
inventory_image = "mobs_meat_raw.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:meat", {
|
minetest.register_craftitem("mobs:meat", {
|
||||||
description = "Meat",
|
description = "Meat",
|
||||||
inventory_image = "mobs_meat.png",
|
inventory_image = "mobs_meat.png",
|
||||||
on_use = minetest.item_eat(8),
|
on_use = minetest.item_eat(8),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "mobs:meat",
|
output = "mobs:meat",
|
||||||
recipe = "mobs:meat_raw",
|
recipe = "mobs:meat_raw",
|
||||||
cooktime = 5,
|
cooktime = 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_animal("mobs:rat", {
|
mobs:register_animal("mobs:rat", {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
collisionbox = {-0.25, -0.175, -0.25, 0.25, 0.1, 0.25},
|
collisionbox = {-0.25, -0.175, -0.25, 0.25, 0.1, 0.25},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=0.7, y=0.35},
|
visual_size = {x=0.7, y=0.35},
|
||||||
textures = {"mobs_rat.png", "mobs_rat.png"},
|
textures = {"mobs_rat.png", "mobs_rat.png"},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
drop = "",
|
drop = "",
|
||||||
drop_count = 0,
|
drop_count = 0,
|
||||||
drawtype = "side",
|
drawtype = "side",
|
||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 1,
|
lava_damage = 1,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if clicker:is_player() and clicker:get_inventory() then
|
if clicker:is_player() and clicker:get_inventory() then
|
||||||
clicker:get_inventory():add_item("main", "mobs:rat")
|
clicker:get_inventory():add_item("main", "mobs:rat")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 5000, 1)
|
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 5000, 1)
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:rat", {
|
minetest.register_craftitem("mobs:rat", {
|
||||||
description = "Rat",
|
description = "Rat",
|
||||||
inventory_image = "mobs_rat.png",
|
inventory_image = "mobs_rat.png",
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.above then
|
if pointed_thing.above then
|
||||||
minetest.env:add_entity(pointed_thing.above, "mobs:rat")
|
minetest.env:add_entity(pointed_thing.above, "mobs:rat")
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:rat_cooked", {
|
minetest.register_craftitem("mobs:rat_cooked", {
|
||||||
description = "Cooked Rat",
|
description = "Cooked Rat",
|
||||||
inventory_image = "mobs_cooked_rat.png",
|
inventory_image = "mobs_cooked_rat.png",
|
||||||
|
|
||||||
on_use = minetest.item_eat(3),
|
on_use = minetest.item_eat(3),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "mobs:rat_cooked",
|
output = "mobs:rat_cooked",
|
||||||
recipe = "mobs:rat",
|
recipe = "mobs:rat",
|
||||||
cooktime = 5,
|
cooktime = 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_monster("mobs:oerkki", {
|
mobs:register_monster("mobs:oerkki", {
|
||||||
hp_max = 8,
|
hp_max = 8,
|
||||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
visual_size = {x=1, y=2},
|
visual_size = {x=1, y=2},
|
||||||
textures = {"mobs_oerkki.png", "mobs_oerkki_back.png"},
|
textures = {"mobs_oerkki.png", "mobs_oerkki_back.png"},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
view_range = 15,
|
view_range = 15,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
damage = 4,
|
damage = 4,
|
||||||
drop = "",
|
drop = "",
|
||||||
drop_count = 0,
|
drop_count = 0,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 1,
|
lava_damage = 1,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)
|
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 411 B |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 920 B |
Before Width: | Height: | Size: 1016 B After Width: | Height: | Size: 1016 B |
Before Width: | Height: | Size: 990 B After Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 909 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -1,4 +1,4 @@
|
|||||||
minetest-mod-slimes
|
minetest-mod-slimes
|
||||||
===================
|
===================
|
||||||
|
|
||||||
This mod adds slimes to minetest-c55
|
This mod adds slimes to minetest-c55
|
@ -1 +1 @@
|
|||||||
mesecons_materials
|
mesecons_materials
|
@ -1,134 +1,134 @@
|
|||||||
SLIME_SIZE = 0.5
|
SLIME_SIZE = 0.5
|
||||||
SLIME_BOX = math.sqrt(2*math.pow(SLIME_SIZE, 2))/2
|
SLIME_BOX = math.sqrt(2*math.pow(SLIME_SIZE, 2))/2
|
||||||
GRAVITY = 9.8
|
GRAVITY = 9.8
|
||||||
|
|
||||||
minetest.register_entity("slimes:small",{
|
minetest.register_entity("slimes:small",{
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
hp_max = 4,
|
hp_max = 4,
|
||||||
visual_size = {x = SLIME_SIZE, y = SLIME_SIZE, z = SLIME_SIZE},
|
visual_size = {x = SLIME_SIZE, y = SLIME_SIZE, z = SLIME_SIZE},
|
||||||
visual = "cube",
|
visual = "cube",
|
||||||
textures = {
|
textures = {
|
||||||
"slime_top.png",
|
"slime_top.png",
|
||||||
"slime_bottom.png",
|
"slime_bottom.png",
|
||||||
"slime_front.png",
|
"slime_front.png",
|
||||||
"slime_sides.png",
|
"slime_sides.png",
|
||||||
"slime_sides.png",
|
"slime_sides.png",
|
||||||
"slime_sides.png",
|
"slime_sides.png",
|
||||||
},
|
},
|
||||||
collisionbox = {-SLIME_BOX, -SLIME_SIZE/2, -SLIME_BOX, SLIME_BOX, SLIME_SIZE/2, SLIME_BOX},
|
collisionbox = {-SLIME_BOX, -SLIME_SIZE/2, -SLIME_BOX, SLIME_BOX, SLIME_SIZE/2, SLIME_BOX},
|
||||||
physical = true,
|
physical = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
timer = 6,
|
timer = 6,
|
||||||
timer2 = 1,
|
timer2 = 1,
|
||||||
timer3 = 0, --regularly check if slime touches ground and possibly set x/z velocity/acceleration to 0
|
timer3 = 0, --regularly check if slime touches ground and possibly set x/z velocity/acceleration to 0
|
||||||
yaw = 0,
|
yaw = 0,
|
||||||
direction = {},
|
direction = {},
|
||||||
status = 2, --1 = jump, 2 = rotate
|
status = 2, --1 = jump, 2 = rotate
|
||||||
attracts_slime = true,
|
attracts_slime = true,
|
||||||
found_friend = false,
|
found_friend = false,
|
||||||
|
|
||||||
on_activate = function(self)
|
on_activate = function(self)
|
||||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self)
|
on_punch = function(self)
|
||||||
if self.object:get_hp() <= 0 then
|
if self.object:get_hp() <= 0 then
|
||||||
minetest.env:add_item(self.object:getpos(), "mesecons_materials:glue 4")
|
minetest.env:add_item(self.object:getpos(), "mesecons_materials:glue 4")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
self.timer2 = self.timer2 + dtime
|
self.timer2 = self.timer2 + dtime
|
||||||
if self.status == 2 and (self.timer2 >= 0.5) then
|
if self.status == 2 and (self.timer2 >= 0.5) then
|
||||||
self.timer2 = 1.2
|
self.timer2 = 1.2
|
||||||
self.status = 1
|
self.status = 1
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
if slime_lonely(pos) and not minetest.env:find_node_near(pos, 16, "default:mese") then
|
if slime_lonely(pos) and not minetest.env:find_node_near(pos, 16, "default:mese") then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
self.yaw = slime_getyaw(pos)
|
self.yaw = slime_getyaw(pos)
|
||||||
if self.yaw == false then
|
if self.yaw == false then
|
||||||
self.yaw = math.random() * 360
|
self.yaw = math.random() * 360
|
||||||
self.found_friend = false
|
self.found_friend = false
|
||||||
else
|
else
|
||||||
self.found_friend = true
|
self.found_friend = true
|
||||||
end
|
end
|
||||||
self.object:setyaw(self.yaw)
|
self.object:setyaw(self.yaw)
|
||||||
self.object:set_properties({automatic_rotate = 0})
|
self.object:set_properties({automatic_rotate = 0})
|
||||||
self.direction = {x = math.cos(self.yaw)*2, y = 6, z = math.sin(self.yaw)*2}
|
self.direction = {x = math.cos(self.yaw)*2, y = 6, z = math.sin(self.yaw)*2}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
self.timer3 = self.timer3 + dtime
|
self.timer3 = self.timer3 + dtime
|
||||||
|
|
||||||
if self.timer2 > 1.3 and self.object:getvelocity().y == 0 then
|
if self.timer2 > 1.3 and self.object:getvelocity().y == 0 then
|
||||||
self.object:setvelocity(self.direction)
|
self.object:setvelocity(self.direction)
|
||||||
self.object:setacceleration({x = self.direction.x/5, y = -GRAVITY, z = self.direction.z/5})
|
self.object:setacceleration({x = self.direction.x/5, y = -GRAVITY, z = self.direction.z/5})
|
||||||
self.timer2 = 0
|
self.timer2 = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.timer >= 6 or (self.timer >= 1 and self.found_friend == true)) and self.object:getvelocity().y == 0 then
|
if (self.timer >= 6 or (self.timer >= 1 and self.found_friend == true)) and self.object:getvelocity().y == 0 then
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.timer2 = 0
|
self.timer2 = 0
|
||||||
|
|
||||||
self.status = 2
|
self.status = 2
|
||||||
if not self.found_friend then
|
if not self.found_friend then
|
||||||
self.object:set_properties({automatic_rotate = math.pi * 8})
|
self.object:set_properties({automatic_rotate = math.pi * 8})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.timer3 > 0.07 then
|
if self.timer3 > 0.07 then
|
||||||
vel = self.object:getvelocity()
|
vel = self.object:getvelocity()
|
||||||
if vel.y == 0 and (vel.x ~= 0 or vel.z ~= 0) then
|
if vel.y == 0 and (vel.x ~= 0 or vel.z ~= 0) then
|
||||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||||
end
|
end
|
||||||
self.timer3 = 0
|
self.timer3 = 0
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function slime_lonely (pos)
|
function slime_lonely (pos)
|
||||||
objs = minetest.env:get_objects_inside_radius(pos, 32)
|
objs = minetest.env:get_objects_inside_radius(pos, 32)
|
||||||
for i, obj in pairs(objs) do
|
for i, obj in pairs(objs) do
|
||||||
if obj:is_player() then return false end
|
if obj:is_player() then return false end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function approx(val1, val2, deviation)
|
function approx(val1, val2, deviation)
|
||||||
if val1 + deviation > val2
|
if val1 + deviation > val2
|
||||||
and val1 - deviation < val2 then
|
and val1 - deviation < val2 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function slime_getyaw (pos) -- get yaw, only if objects to follow nearby
|
function slime_getyaw (pos) -- get yaw, only if objects to follow nearby
|
||||||
objs = minetest.env:get_objects_inside_radius(pos, 7)
|
objs = minetest.env:get_objects_inside_radius(pos, 7)
|
||||||
for i, obj in ipairs(objs) do
|
for i, obj in ipairs(objs) do
|
||||||
if obj:is_player() or obj:get_luaentity().name == "slimes:small" then
|
if obj:is_player() or obj:get_luaentity().name == "slimes:small" then
|
||||||
local ppos = {x = obj:getpos().x - pos.x,
|
local ppos = {x = obj:getpos().x - pos.x,
|
||||||
z = obj:getpos().z - pos.z}
|
z = obj:getpos().z - pos.z}
|
||||||
if ppos.x ~= 0 and ppos.z ~= 0 then --found itself as an object
|
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)
|
local yaw = math.abs(math.atan(ppos.x/ppos.z) - math.pi / 2)
|
||||||
if ppos.z < 0 then yaw = yaw + math.pi end
|
if ppos.z < 0 then yaw = yaw + math.pi end
|
||||||
return yaw
|
return yaw
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:leaves"},
|
nodenames = {"default:leaves"},
|
||||||
interval = 10.0,
|
interval = 10.0,
|
||||||
chance = 100000,
|
chance = 100000,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
minetest.env:add_entity({x=pos.x, y=pos.y + 1, z=pos.z}, "slimes:small")
|
minetest.env:add_entity({x=pos.x, y=pos.y + 1, z=pos.z}, "slimes:small")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 493 B After Width: | Height: | Size: 493 B |
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 506 B |
@ -1,140 +1,140 @@
|
|||||||
--[[
|
--[[
|
||||||
|
|
||||||
Bags for Minetest
|
Bags for Minetest
|
||||||
|
|
||||||
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||||
Source Code: https://github.com/cornernote/minetest-particles
|
Source Code: https://github.com/cornernote/minetest-particles
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
|
||||||
-- get_formspec
|
-- get_formspec
|
||||||
local get_formspec = function(player,page)
|
local get_formspec = function(player,page)
|
||||||
if page=="bags" then
|
if page=="bags" then
|
||||||
return "size[8,7.5]"
|
return "size[8,7.5]"
|
||||||
.."list[current_player;main;0,3.5;8,4;]"
|
.."list[current_player;main;0,3.5;8,4;]"
|
||||||
.."button[0,0;2,0.5;main;Back]"
|
.."button[0,0;2,0.5;main;Back]"
|
||||||
.."button[0,2;2,0.5;bag1;Bag 1]"
|
.."button[0,2;2,0.5;bag1;Bag 1]"
|
||||||
.."button[2,2;2,0.5;bag2;Bag 2]"
|
.."button[2,2;2,0.5;bag2;Bag 2]"
|
||||||
.."button[4,2;2,0.5;bag3;Bag 3]"
|
.."button[4,2;2,0.5;bag3;Bag 3]"
|
||||||
.."button[6,2;2,0.5;bag4;Bag 4]"
|
.."button[6,2;2,0.5;bag4;Bag 4]"
|
||||||
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
|
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
|
||||||
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
|
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
|
||||||
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
|
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
|
||||||
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
|
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
|
||||||
end
|
end
|
||||||
for i=1,4 do
|
for i=1,4 do
|
||||||
if page=="bag"..i then
|
if page=="bag"..i then
|
||||||
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
|
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
|
||||||
return "size[8,8.5]"
|
return "size[8,8.5]"
|
||||||
.."list[current_player;main;0,4.5;8,4;]"
|
.."list[current_player;main;0,4.5;8,4;]"
|
||||||
.."button[0,0;2,0.5;main;Main]"
|
.."button[0,0;2,0.5;main;Main]"
|
||||||
.."button[2,0;2,0.5;bags;Bags]"
|
.."button[2,0;2,0.5;bags;Bags]"
|
||||||
.."image[7,0;1,1;"..image.."]"
|
.."image[7,0;1,1;"..image.."]"
|
||||||
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
|
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register_on_player_receive_fields
|
-- register_on_player_receive_fields
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.bags then
|
if fields.bags then
|
||||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
|
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i=1,4 do
|
for i=1,4 do
|
||||||
local page = "bag"..i
|
local page = "bag"..i
|
||||||
if fields[page] then
|
if fields[page] then
|
||||||
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
|
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
|
||||||
page = "bags"
|
page = "bags"
|
||||||
end
|
end
|
||||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
|
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- register_on_joinplayer
|
-- register_on_joinplayer
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
inventory_plus.register_button(player,"bags","Bags")
|
inventory_plus.register_button(player,"bags","Bags")
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
|
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
|
||||||
on_put = function(inv, listname, index, stack, player)
|
on_put = function(inv, listname, index, stack, player)
|
||||||
player:get_inventory():set_stack(listname, index, stack)
|
player:get_inventory():set_stack(listname, index, stack)
|
||||||
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
|
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
|
||||||
end,
|
end,
|
||||||
on_take = function(inv, listname, index, stack, player)
|
on_take = function(inv, listname, index, stack, player)
|
||||||
player:get_inventory():set_stack(listname, index, nil)
|
player:get_inventory():set_stack(listname, index, nil)
|
||||||
end,
|
end,
|
||||||
allow_put = function(inv, listname, index, stack, player)
|
allow_put = function(inv, listname, index, stack, player)
|
||||||
if stack:get_definition().groups.bagslots then
|
if stack:get_definition().groups.bagslots then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_take = function(inv, listname, index, stack, player)
|
allow_take = function(inv, listname, index, stack, player)
|
||||||
if player:get_inventory():is_empty(listname.."contents")==true then
|
if player:get_inventory():is_empty(listname.."contents")==true then
|
||||||
return stack:get_size(listname)
|
return stack:get_count()
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
for i=1,4 do
|
for i=1,4 do
|
||||||
local bag = "bag"..i
|
local bag = "bag"..i
|
||||||
player_inv:set_size(bag, 1)
|
player_inv:set_size(bag, 1)
|
||||||
bags_inv:set_size(bag, 1)
|
bags_inv:set_size(bag, 1)
|
||||||
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
|
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- register bag tools
|
-- register bag tools
|
||||||
minetest.register_tool("bags:small", {
|
minetest.register_tool("bags:small", {
|
||||||
description = "Small Bag",
|
description = "Small Bag",
|
||||||
inventory_image = "bags_small.png",
|
inventory_image = "bags_small.png",
|
||||||
groups = {bagslots=8},
|
groups = {bagslots=8},
|
||||||
})
|
})
|
||||||
minetest.register_tool("bags:medium", {
|
minetest.register_tool("bags:medium", {
|
||||||
description = "Medium Bag",
|
description = "Medium Bag",
|
||||||
inventory_image = "bags_medium.png",
|
inventory_image = "bags_medium.png",
|
||||||
groups = {bagslots=16},
|
groups = {bagslots=16},
|
||||||
})
|
})
|
||||||
minetest.register_tool("bags:large", {
|
minetest.register_tool("bags:large", {
|
||||||
description = "Large Bag",
|
description = "Large Bag",
|
||||||
inventory_image = "bags_large.png",
|
inventory_image = "bags_large.png",
|
||||||
groups = {bagslots=24},
|
groups = {bagslots=24},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- register bag crafts
|
-- register bag crafts
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "bags:small",
|
output = "bags:small",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:stick", ""},
|
{"", "default:stick", ""},
|
||||||
{"default:wood", "default:wood", "default:wood"},
|
{"default:wood", "default:wood", "default:wood"},
|
||||||
{"default:wood", "default:wood", "default:wood"},
|
{"default:wood", "default:wood", "default:wood"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "bags:medium",
|
output = "bags:medium",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:stick", ""},
|
{"", "default:stick", ""},
|
||||||
{"bags:small", "bags:small", "bags:small"},
|
{"bags:small", "bags:small", "bags:small"},
|
||||||
{"bags:small", "bags:small", "bags:small"},
|
{"bags:small", "bags:small", "bags:small"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "bags:large",
|
output = "bags:large",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:stick", ""},
|
{"", "default:stick", ""},
|
||||||
{"bags:medium", "bags:medium", "bags:medium"},
|
{"bags:medium", "bags:medium", "bags:medium"},
|
||||||
{"bags:medium", "bags:medium", "bags:medium"},
|
{"bags:medium", "bags:medium", "bags:medium"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- log that we started
|
-- log that we started
|
||||||
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))
|
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))
|