Compare commits

...

5 Commits

Author SHA1 Message Date
ac-minetest 3c17a5257a 'test' 2021-02-15 11:59:23 +01:00
rnd1 839994dbb6 campfire can be used by anyone 2015-11-08 23:26:23 +01:00
rnd1 0572c658f9 .. 2015-11-07 10:31:12 +01:00
rnd1 f63a85b791 readme 2015-11-06 20:28:29 +01:00
rnd1 56db072407 .. 2015-11-06 20:20:46 +01:00
2 changed files with 73 additions and 52 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
Campfire by rnd
(attempt to make gameplay more tactical)
Background story:
You find yourself on cold planet. To warm up you need to place campfire or you will freeze.
Campfire is built with 2 cobble (cobble,empty,cobble) it can be lighted using tree fuel by punching it. It needs
to be built within 10 block distance to other active campfire owned by you or ADMIN or it wont be possible to light it up.
You need to be close to active campfire owned by you or ADMIN or you start loosing health. After you die you have 1 free minute to get to campfire or your bones.
Any player can dig unprotected active campfire but they cant dig campfire owned by ADMIN.

113
init.lua
View File

@ -1,17 +1,20 @@
-- idea: cant stay away from your active fire too long or die, fuel cost increases with distance from spawn
-- EMAIL VERIFICATION FOR GITHUB february 15th 2021 ac-minetest
-- campfire gameplay mod by rnd
local campfire = {};
campfire.radius = 10;
campfire.timestep = 5;
campfire.damage = 5;
campfire.radius = 10; -- inside this radius no damage
campfire.damage = 5; -- damage per step when away from fire
campfire.timeout = 10; -- how long can you stay outside fire area before you start loosing hp
campfire.cost = 2/100; -- cost of making new fire active, per 1 block distance from spawn
campfire.count = {}; -- how many fires have you placed already
campfire.fire_pos = {};
campfire.fire_timer = {};
local spawn_pos = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0})
campfire.count = {}; -- how many fires have you placed already, not yet used
campfire.fire_pos = {}; -- last known fire position
campfire.fire_timer = {};
campfire.timestep = 5; -- time step to run mod
local spawn_pos = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0})
campfire.time = 0; -- global timer
local time = 0;
minetest.register_node("campfire:fire_active", {
description = "camp fire",
@ -21,6 +24,7 @@ minetest.register_node("campfire:fire_active", {
sounds = default.node_sound_stone_defaults(),
groups = {cracky = 3},
is_ground_content = false,
walkable = false,
paramtype = "light",
light_source = 10,
node_box = {
@ -29,9 +33,10 @@ minetest.register_node("campfire:fire_active", {
{-0.5 ,-0.5, -0.5, 0.5, 0.5, 0.5},
}
},
can_dig = function(pos, player)
can_dig = function(pos, player) -- you cant dig active fire owned my admin or inside protection
local meta = minetest.get_meta(pos);
if meta:get_string("owner")~="ADMIN" then
local name = player:get_player_name();
if (meta:get_string("owner")~="ADMIN" and not( minetest.is_protected(pos,name) )) or minetest.check_player_privs(name, {privs = true}) then
minetest.set_node(pos,{name = "air"});
end
return false
@ -50,6 +55,7 @@ minetest.register_node("campfire:fire", {
sounds = default.node_sound_stone_defaults(),
groups = {cracky = 3},
is_ground_content = false,
walkable = false,
paramtype = "light",
light_source = 0,
node_box = {
@ -75,10 +81,8 @@ minetest.register_node("campfire:fire", {
local pmeta = minetest.get_meta(p); local owner = pmeta:get_string("owner");
fire = true;
--count = math.max(pmeta:get_int("count"), count);
meta:set_int("ignitable",1); -- new fire can be ignited with fuel
--meta:set_int("count",count);
--campfire.count[name] = count;
-- cost of igniting the campfire
cost = math.sqrt(math.pow(spawn_pos.x-pos.x,2)+math.pow(spawn_pos.y-pos.y,2)+math.pow(spawn_pos.z-pos.z,2));
cost = campfire.cost*cost; cost = math.ceil(cost); -- cost depends on distance from spawn?
meta:set_int("cost",cost);
@ -87,7 +91,7 @@ minetest.register_node("campfire:fire", {
end
if not fire then
meta:set_string("infotext","inactive campfire ( owned by ".. name .."), place it closer (".. campfire.radius .. " blocks ) to existing active campfire owned by you or ADMIN. ");
meta:set_string("infotext","inactive campfire ( owned by ".. name .."), place it closer (".. campfire.radius .. " blocks ) to existing active campfire. ");
end
end,
@ -115,49 +119,20 @@ minetest.register_node("campfire:fire", {
end
meta:set_string("infotext","active fire ( owned by ".. meta:get_string("owner") ..")");
end,
can_dig = function(pos, player)
can_dig = function(pos, player) -- inactive fire can be dug up by everyone, everywhere
local candig = true
--minetest.check_player_privs(player:get_player_name(), {privs = true}) or (player:get_player_name()==meta:get_string("owner"));
minetest.set_node(pos,{name = "air"});
return true
end
});
minetest.register_craft({
output = "campfire:fire",
recipe = {
{"default:cobble","","default:cobble"}
}
})
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name() or "";
campfire.fire_timer[name] = minetest.get_gametime()+60;
local pos = player:getpos();
campfire.fire_pos[name] = pos;
minetest.chat_send_player(name,"You have one minute to get near active campfire owned by you or ADMIN or return to your bones ( " .. pos.x .. " " .. pos.y .. " " .. pos.z .. " ).")
end
)
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name() or "";
if not campfire.fire_pos[name] then campfire.fire_pos[name] = player:getpos(); end
if not campfire.fire_timer[name] then
campfire.fire_timer[name] = minetest.get_gametime()+60;
minetest.chat_send_player(name,"You have one minute to get near active campfire owned by you or ADMIN.")
end
if not campfire.count[name] then campfire.count[name] = 0 end
end
)
minetest.register_globalstep(function(dtime)
time = time + dtime
if time < campfire.timestep then return end
time = 0;
campfire.time = campfire.time + dtime
if campfire.time < campfire.timestep then return end
campfire.time = 0;
local t1,t2,player;
t2 = minetest.get_gametime();
@ -180,10 +155,10 @@ minetest.register_globalstep(function(dtime)
local pos = minetest.find_node_near(p, campfire.radius, "campfire:fire_active");
if pos then
local meta = minetest.get_meta(pos); local owner = meta:get_string("owner");
if owner == name or owner == "ADMIN" then
--if owner == name or owner == "ADMIN" then -- TO DO: make fire private with sneak + punch
fire = true
campfire.fire_pos[name] = pos; -- set newly found campfire as new campfire position
end
--end
end
else
fire = true
@ -191,8 +166,8 @@ minetest.register_globalstep(function(dtime)
if not fire then
if player:get_hp()>0 then
minetest.chat_send_player(name,"You need to get close (" .. campfire.radius .." blocks) to active campfire you own to stop taking damage ");
player:set_hp(player:get_hp() - campfire.damage)
minetest.chat_send_player(name,"You need to get close (" .. campfire.radius .." blocks) to active campfire to stop taking damage ");
player:set_hp(player:get_hp() - campfire.damage);
end
else
campfire.fire_timer[name] = t2;
@ -202,3 +177,37 @@ minetest.register_globalstep(function(dtime)
end
end
)
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name() or "";
campfire.fire_timer[name] = minetest.get_gametime()+60;
local pos = player:getpos();
campfire.fire_pos[name] = pos;
minetest.chat_send_player(name,"You have one minute to get near active campfire or return to your bones ( " .. pos.x .. " " .. pos.y .. " " .. pos.z .. " ).")
end
)
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name() or "";
if not campfire.fire_pos[name] then campfire.fire_pos[name] = player:getpos(); end
if not campfire.fire_timer[name] then
campfire.fire_timer[name] = minetest.get_gametime()+60;
minetest.chat_send_player(name,"You have one minute to get near active campfire.")
end
if not campfire.count[name] then campfire.count[name] = 0 end
--player:set_physics_override({speed = 0.75}) -- for testing only
end
)
-- CRAFT RECIPE
minetest.register_craft({
output = "campfire:fire",
recipe = {
{"default:cobble","","default:cobble"}
}
})