Compare commits

..

2 Commits

Author SHA1 Message Date
BadToad2000
110234c7ce Merge remote-tracking branch 'Brema/master'
Just getting current with Bremaweb.
2016-09-24 00:05:08 -05:00
BadToad
b1bc35f68a Use register_lbm to update existing formspecs so that SHIFT-CLICK works
for nodes which existed prior to that formspec change.

Also, fix errors (crashed) when using affect and removeaffect chat commands.
2016-09-23 23:33:24 -05:00
28 changed files with 166 additions and 430 deletions

View File

@ -1,92 +0,0 @@
### migration to mt 5.0/5.2
There are the issues Tignasse Verte mentionned: Adding `placer` in `register_functions.lua`
(related commit for minenux are commit a996d5ac709446322d6c6261c21e5f0752a6aeeb )
and replacing the two occourances of `nodeupdate` with `minetest.check_for_falling`.
(relatd commit for minenux are commit 8c53cabfce2d079df76e57b27b020e016837e8fc )
Other changes are necessary because I changed (and had to change) quite a lot
in `mg_villages` internally recently. If you want to get further with running
the game under newer versions of MT, replace the versions of `cottages`, `handle_schematics`
and `mg_villages` AdventureTest comes with with the newest versions.
Then, remove the line `mg_villages.on_generated(minp,maxp,seed)` in
`adventuretest/register_functions.lua`. This may have an impact on quests the
old explorer is handling out, but if you ignore these for now, the world ought to be usable.
Comment out the file/content of `mg/fill_chests.lua` for now as that requires
a few adjustments for filling the chests with the right content, and that's a bit
too much to write here in an inconvenient forum post.
You won't see any villagers spawning because their spawn blocks are not placed.
My first attempts there ended in a severe overcrowding of villagers. Needs
finetuning/understanding what BrandonReese did to keep it balanced. But then,
this seems to be an open issue on Github as well...
Mobs will likely not work very well. A lot changed regarding them.
They certainly could use an update as well - as could the goblins. I'm sure the witches
from the same modder would feel welcome in the AdventureTest universe, too.
### Fiel of view for monsters vs characters
From https://forum.minetest.net/viewtopic.php?p=182737#p182737
If it helps any, here is the in_fov code from mobs redo mod that works (self is mob, pos is player position and self.fov is set to 90, self.rotate is usually 0 for front facing mobs):
CODE: SELECT ALL
```
in_fov = function(self,pos)
-- checks if POS is in self's FOV
local yaw = self.object:getyaw() + self.rotate
local vx = math.sin(yaw)
local vz = math.cos(yaw)
local ds = math.sqrt(vx^2 + vz^2)
local ps = math.sqrt(pos.x^2 + pos.z^2)
local d = { x = vx / ds, z = vz / ds }
local p = { x = pos.x / ps, z = pos.z / ps }
local an = ( d.x * p.x ) + ( d.z * p.z )
a = math.deg( math.acos( an ) )
```
Thank you everyone, especially TeTpaAka and Nore. All problems were at last solved, and the code now reports the angle difference between entities like it should! You get 0* when standing right in front of the mob, 90* when standing parallel to either side, 180* when standing behind... whereas flying up or down now accounts pitch correctly on top of that.
Here is the final and fully functional version. I hope it will be helpful to more people than just me, if anyone ever needs a simple and efficient FOV scanner for Minetest.
```
local function in_fov (pos1, pos2, yaw, pitch, fov)
local function yaw2vec (yaw, pitch)
-- we must invert the yaw for x to keep the result from inverting when facing opposite directions (0* becoming 180*)
return {x = math.sin(-yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)}
end
local function dotproduct (v1, v2)
return ((v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z))
end
local function angle (v1, v2)
return math.deg(math.acos(dotproduct(v1, v2) / (vector.length(v1) * vector.length(v2))))
end
local v = vector.subtract(pos2, pos1)
print(angle(yaw2vec(yaw, pitch), v))
end
```
here is the final version of the function which I'll be including in my mod, simplified to only 5 lines of code but with the same result:
CODE: SELECT ALL
```
-- returns the angle difference between pos1 and pos2, as seen from pos1 at the specified yaw and pitch
function pos_to_angle (pos1, pos2, yaw, pitch)
-- note: we must invert the yaw for x in yaw_vec, to keep the result from inverting when facing opposite directions (0* becoming 180*)
local yaw_vec = {x = -math.sin(yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)}
local pos_subtract = vector.subtract(pos2, pos1)
local pos_dotproduct = (yaw_vec.x * pos_subtract.x) + (yaw_vec.y * pos_subtract.y) + (yaw_vec.z * pos_subtract.z)
local angle = math.deg(math.acos(pos_dotproduct / (vector.length(yaw_vec) * vector.length(pos_subtract))))
return angle
end
```

116
README.md
View File

@ -1,116 +0,0 @@
Adventuretest game for the Minetest game engine
==========================================================
To play this game in Minetest, insert this repository as
/games/adventuretest
in the Minetest Engine.
The Minetest Engine that can play this game can be found at
https://minetest.io/ or just build your version using the minenux branch
at https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0
![screenshot.png](screenshot.png)
INFORMATION
-----------
The game has a RPG spirit, but not limit to, its focused in
singleplayer, but also works for multiplayer too, creative and
damage are mutually exclusive settings.
#### Quests
The game have "quests" that any player can do, some have rewards
others just provide rare things,
A common rquest is Right click on any of the ladies in the village
with black hair to receive your quest.
#### Crafting guides
Build in in the lifesaver button, There is a crafting guide,
of the inventory. also once in the game type `/m` and press
enter and you will get a crafting guide, equipping armor form
and changing skin form.
### Configuration
By default each interaction of attack causes blood, but you
can configure to make the enemy just cry with `enable_blood` to `false`
### Know issues
If yu got crash, somethigns you game get slow for movement, in singleplayer,
the character suddently stop and if you tryto move, keep moving until
a block just stop it.
To solve, go into your world directory and delete the affects.txt
and physics file. This happens sometimes when there is a crash.
Adventuretest License
------------------------------------------
Copyright (C) 2013-2014 Brandon Bohannon <brandon@bremaweb.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
License of default mods source code
-----------------------------------
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
See README.txt in each mod directory for information about other authors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
License of media (models, textures and sounds)
--------------------------------------
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
See README.txt in each mod directory for information about other authors.
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
http://creativecommons.org/licenses/by-sa/3.0/
License of menu/header.png
Copyright (C) 2013 BlockMen CC BY-3.0
License of Spider model
Copyright (C) 2013 AspireMint CC BY-SA
goblins_goblin.b3d and goblins_goblin.blend
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) by FreeLikeGNU
http://creativecommons.org/licenses/by-sa/3.0/
above meshes based on character from minetest_game
MirceaKitsune (WTFPL)
https://github.com/minetest/minetest_game/blob/master/mods/default/README.txt#L71
goblins_goblins*.png files and goblins_goblin.xcf file by FreeLikeGNU
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) FreeLikeGNU
http://creativecommons.org/licenses/by-sa/3.0/
Thanks to Napiophelios for the goblin king skin
https://forum.minetest.net/viewtopic.php?f=9&t=13004#p186921
goblins_goblin_king.png
License: Creative Commons CC-BY-SA-3.0 SummerFeilds TP

View File

@ -5,46 +5,8 @@ To play this game in Minetest, insert this repository as
/games/adventuretest /games/adventuretest
in the Minetest Engine. in the Minetest Engine.
The Minetest Engine that can play this game can be found at The Minetest Engine can be found in:
https://minetest.io/ or just build your version using the minenux branch https://github.com/minetest/minetest/
at https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0
![screenshot.png](screenshot.png)
INFORMATION
-----------
The game has a RPG spirit, but not limit to, its focused in
singleplayer, but also works for multiplayer too, creative and
damage are mutually exclusive settings.
#### Quests
The game have "quests" that any player can do, some have rewards
others just provide rare things,
A common rquest is Right click on any of the ladies in the village
with black hair to receive your quest.
#### Crafting guides
Build in in the lifesaver button, There is a crafting guide,
of the inventory. also once in the game type `/m` and press
enter and you will get a crafting guide, equipping armor form
and changing skin form.
### Configuration
By default each interaction of attack causes blood, but you
can configure to make the enemy just cry with `enable_blood` to `false`
### Know issues
If yu got crash, somethigns you game get slow for movement, in singleplayer,
the character suddently stop and if you tryto move, keep moving until
a block just stop it.
To solve, go into your world directory and delete the affects.txt
and physics file. This happens sometimes when there is a crash.
Adventuretest License Adventuretest License
------------------------------------------ ------------------------------------------

View File

@ -1,8 +1 @@
title = adventuretest name = Adventuretest
name = adventuretest
author = bremaweb
description = Adventure RPG-hard game for the Minetest game engine
release = 20181212
min_minetest_version = 0.4.14
max_minetest_version = 4.99
disabled_settings = creative_mode, !enable_damage

View File

@ -5,8 +5,6 @@ enable_node_highlighting = true
debug_log_level = action debug_log_level = action
enable_blood = true
torches_enable_ceiling = false torches_enable_ceiling = false
torches_style = minetest torches_style = minetest

View File

@ -22,17 +22,22 @@ end
adventuretest.pl_hooks = {} adventuretest.pl_hooks = {}
function adventuretest.player_loop(dtime) function adventuretest.player_loop(dtime)
local p = minetest.get_connected_players() local p = minetest.get_connected_players()
local reset_hooks = {} local reset_hooks = { }
for k,hook in pairs(adventuretest.pl_hooks) do for _, player in pairs(p) do
adventuretest.pl_hooks[k].timer = adventuretest.pl_hooks[k].timer + dtime local name = player:get_player_name()
if adventuretest.pl_hooks[k].timer >= adventuretest.pl_hooks[k].timeout then for k,hook in pairs(adventuretest.pl_hooks) do
for _, player in pairs(p) do adventuretest.pl_hooks[k].timer = adventuretest.pl_hooks[k].timer + dtime
local name = player:get_player_name() if adventuretest.pl_hooks[k].timer >= adventuretest.pl_hooks[k].timeout then
adventuretest.pl_hooks[k].timer = 0 reset_hooks[#reset_hooks+1] = k
adventuretest.pl_hooks[k].func(player,name,dtime) adventuretest.pl_hooks[k].func(player,name,dtime)
end end
end end
end end
if #reset_hooks > 0 then
for _,hid in pairs(reset_hooks) do
adventuretest.pl_hooks[hid].timer = 0
end
end
end end
function adventuretest.register_pl_hook(f,t) function adventuretest.register_pl_hook(f,t)

View File

@ -3,11 +3,6 @@ adventuretest = {}
adventuretest.seed = os.time() adventuretest.seed = os.time()
local enable_blood
if minetest.setting_get("enable_blood") ~= nil then
enable_blood = minetest.setting_getbool("enable_blood") or true
end
game_origin = nil game_origin = nil
if minetest.setting_get("game_origin") ~= nil then if minetest.setting_get("game_origin") ~= nil then
game_origin = minetest.string_to_pos(minetest.setting_get("game_origin")) game_origin = minetest.string_to_pos(minetest.setting_get("game_origin"))
@ -15,31 +10,6 @@ else
game_origin = {x=0,y=3,z=0} game_origin = {x=0,y=3,z=0}
end end
adventuretest.blood = enable_blood
-- check for minetest 5.x compatibility and mantains backguard 4.X/0.4
local is_57 = minetest.has_feature("get_light_data_buffer")
local is_56 = minetest.has_feature("particlespawner_tweenable")
local is_55 = minetest.has_feature("dynamic_add_media_table")
local is_54 = minetest.has_feature("direct_velocity_on_players")
local is_53 = minetest.has_feature("object_step_has_moveresult")
local is_52 = minetest.has_feature("pathfinder_works")
local is_51 = minetest.has_feature("httpfetch_binary_data")
local is_50 = minetest.has_feature("object_use_texture_alpha")
local is_04 = minetest.has_feature("area_store_custom_ids")
local is_40 = minetest.has_feature("add_entity_with_staticdata")
-- expose api check of minetest version compatibility, 40 is 4.0.17+ and 0.4 is 0.4.14 to 0.4.17.1
adventuretest.is_57 = is_57
adventuretest.is_56 = is_56
adventuretest.is_55 = is_55
adventuretest.is_54 = is_54
adventuretest.is_53 = is_53
adventuretest.is_52 = is_52
adventuretest.is_51 = is_51
adventuretest.is_50 = is_50
adventuretest.is_04 = is_04
adventuretest.is_40 = is_40
dofile(minetest.get_modpath("adventuretest").."/functions.lua"); dofile(minetest.get_modpath("adventuretest").."/functions.lua");
dofile(minetest.get_modpath("adventuretest").."/register_functions.lua"); dofile(minetest.get_modpath("adventuretest").."/register_functions.lua");
dofile(minetest.get_modpath("adventuretest").."/privs.lua") dofile(minetest.get_modpath("adventuretest").."/privs.lua")

View File

@ -98,7 +98,7 @@ minetest.register_on_dignode(adventuretest_dignode)
local function adventuretest_placenode(pos, node, placer) local function adventuretest_placenode(pos, node, placer)
hunger.handle_node_actions(pos,node,placer) hunger.handle_node_actions(pos,node,placer)
if placer and placer:is_player() then if placer:is_player() then
local name = placer:get_player_name() local name = placer:get_player_name()
pd.increment(name,STAT_PLACED,1) pd.increment(name,STAT_PLACED,1)

View File

@ -17,11 +17,13 @@ minetest.register_chatcommand("affect",{
minetest.register_chatcommand("removeaffect",{ minetest.register_chatcommand("removeaffect",{
params = "<name> [affectid]", params = "<name> [affectid]",
description = "Removes and affect or all affects from a player", description = "Remove an affect or all affects from a player",
privs = {affects=true}, privs = {affects=true},
func = function (name, param) func = function (name, param)
local aname, affectid = string.match(param, "([^ ]+) (.+)") local aname, affectid = string.match(param, "([^ ]+) (.+)")
if ( affects.removeAffect(aname,affectid) ) then if ( aname == nil or aname == "" ) then
minetest.chat_send_player(name, "Syntax: removeaffect <name> [affectid]")
elseif ( affects.removeAffect(aname,affectid) ) then
minetest.chat_send_player(name,"Affect removed from "..aname) minetest.chat_send_player(name,"Affect removed from "..aname)
else else
minetest.chat_send_player(name,"Unable to remove affects") minetest.chat_send_player(name,"Unable to remove affects")

View File

@ -46,8 +46,8 @@ local cottages_anvil_formspec =
"label[0,3.0;"..S("Punch anvil with hammer to").."]".. "label[0,3.0;"..S("Punch anvil with hammer to").."]"..
"label[0,3.3;"..S("repair tool in workpiece-slot.").."]".. "label[0,3.3;"..S("repair tool in workpiece-slot.").."]"..
"list[current_player;main;0,4;8,4;]" "list[current_player;main;0,4;8,4;]"
.."listring[current_player;main]".."listring[current_name;hammer]"
.."listring[current_player;main]".."listring[current_name;input]" .."listring[current_player;main]".."listring[current_name;input]"
.."listring[current_player;main]".."listring[current_name;hammer]"
minetest.register_node("cottages:anvil", { minetest.register_node("cottages:anvil", {
@ -303,3 +303,18 @@ minetest.register_craft({
{'', cottages.craftitem_stick, '' } } {'', cottages.craftitem_stick, '' } }
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "cottages:anvil_lbm",
nodenames = {"cottages:anvil"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
cottages_anvil_formspec..
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]");
end,
})

View File

@ -25,25 +25,25 @@ local S = cottages.S
barrel = {}; barrel = {};
local barrel_formspec = "size[8,9]"..
"image[2.6,2;2,3;default_sandstone.png^[lowpart:"..
-- (100-percent)..":default_desert_stone.png]".. -- TODO: better images
"50:default_desert_stone.png]".. -- TODO: better images
"label[2.2,0;"..S("Pour:").."]"..
"list[current_name;input;3,0.5;1,1;]"..
"label[5,3.3;"..S("Fill:").."]"..
"list[current_name;output;5,3.8;1,1;]"..
"list[current_player;main;0,5;8,4;]"
.."listring[current_name;output]".."listring[current_player;main]"
.."listring[current_name;input]".."listring[current_player;main]"
-- prepare formspec -- prepare formspec
barrel.on_construct = function( pos ) barrel.on_construct = function( pos )
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local percent = math.random( 1, 100 ); -- TODO: show real filling local percent = math.random( 1, 100 ); -- TODO: show real filling
meta:set_string( 'formspec', meta:set_string( 'formspec', barrel_formspec)
"size[8,9]"..
"image[2.6,2;2,3;default_sandstone.png^[lowpart:"..
(100-percent)..":default_desert_stone.png]".. -- TODO: better images
"label[2.2,0;"..S("Pour:").."]"..
"list[current_name;input;3,0.5;1,1;]"..
"label[5,3.3;"..S("Fill:").."]"..
"list[current_name;output;5,3.8;1,1;]"..
"list[current_player;main;0,5;8,4;]"
.."listring[current_name;output]".."listring[current_player;main]"
.."listring[current_name;input]".."listring[current_player;main]"
)
meta:set_string( 'liquid_type', '' ); -- which liquid is in the barrel? meta:set_string( 'liquid_type', '' ); -- which liquid is in the barrel?
meta:set_int( 'liquid_level', 0 ); -- how much of the liquid is in there? meta:set_int( 'liquid_level', 0 ); -- how much of the liquid is in there?
@ -223,3 +223,17 @@ minetest.register_craft({
{"cottages:tub"}, {"cottages:tub"},
}, },
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "cottages:barrel_lbm",
nodenames = {"cottages:barrel"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", barrel_formspec)
end,
})

View File

@ -59,3 +59,16 @@ minetest.register_node("cottages:chest_storage", {
is_ground_content = false, is_ground_content = false,
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "cottages:chests_lbm",
nodenames = {"cottages:chest_private", "cottages:chest_work", "cottages:chest_storage"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.chest_formspec)
end,
})

View File

@ -189,6 +189,12 @@ end
minetest.register_node("cottages:table", cottages_table_def ); minetest.register_node("cottages:table", cottages_table_def );
local cottage_shelf_formspec =
"size[8,8]"..
"list[current_name;main;0,0;8,3;]"..
"list[current_player;main;0,4;8,4;]"..
"listring[]"
-- looks better than two slabs impersonating a shelf; also more 3d than a bookshelf -- looks better than two slabs impersonating a shelf; also more 3d than a bookshelf
-- the infotext shows if it's empty or not -- the infotext shows if it's empty or not
minetest.register_node("cottages:shelf", { minetest.register_node("cottages:shelf", {
@ -221,11 +227,7 @@ minetest.register_node("cottages:shelf", {
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
meta:set_string("formspec", meta:set_string("formspec", cottage_shelf_formspec)
"size[8,8]"..
"list[current_name;main;0,0;8,3;]"..
"list[current_player;main;0,4;8,4;]"..
"listring[current_name;main]".."listring[current_player;main]")
meta:set_string("infotext", S("open storage shelf")) meta:set_string("infotext", S("open storage shelf"))
local inv = meta:get_inventory(); local inv = meta:get_inventory();
inv:set_size("main", 24); inv:set_size("main", 24);
@ -390,3 +392,16 @@ minetest.register_craft({
} }
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "cottages:shelf_lbm",
nodenames = {"cottages:shelf"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", cottage_shelf_formspec)
end,
})

View File

@ -99,8 +99,8 @@ local cottages_formspec_treshing_floor =
"label[0,3.0;"..S("to get straw and seeds from wheat.").."]".. "label[0,3.0;"..S("to get straw and seeds from wheat.").."]"..
"list[current_player;main;0,4;8,4;]" "list[current_player;main;0,4;8,4;]"
.."listring[current_name;straw]".."listring[current_player;main]" .."listring[current_name;straw]".."listring[current_player;main]"
.."listring[current_name;seeds]".."listring[current_player;main]"
.."listring[current_name;harvest]".."listring[current_player;main]" .."listring[current_name;harvest]".."listring[current_player;main]"
.."listring[current_name;seeds]".."listring[current_player;main]"
minetest.register_node("cottages:threshing_floor", { minetest.register_node("cottages:threshing_floor", {
drawtype = "nodebox", drawtype = "nodebox",
@ -576,3 +576,31 @@ minetest.register_craft({
{"cottages:straw","cottages:straw","cottages:straw"}, {"cottages:straw","cottages:straw","cottages:straw"},
}, },
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "cottages:threshing_floor_lbm",
nodenames = {"cottages:threshing_floor"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
cottages_formspec_treshing_floor..
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" );
end,
})
minetest.register_lbm({
name = "cottages:handmill_lbm",
nodenames = {"cottages:handmill"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
cottages_handmill_formspec..
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" );
end,
})

View File

@ -144,7 +144,6 @@ if minetest.setting_getbool("creative_mode") then
}) })
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
minetest.log("warning","[creative] maybe missing check for player here?")
return true return true
end) end)

View File

@ -382,11 +382,7 @@ minetest.register_abm({
end end
-- Remove node -- Remove node
minetest.remove_node(p0) minetest.remove_node(p0)
if adventuretest.is_50 then nodeupdate(p0)
minetest.check_for_falling(p0)
else
nodeupdate(p0)
end
end end
end end
}) })

View File

@ -925,6 +925,19 @@ minetest.register_abm({
end, end,
}) })
--------------------------------------------------------------------------------
-- Update existing nodes to use SHIFT-CLICK
--------------------------------------------------------------------------------
minetest.register_lbm({
name = "default:chest_lbm",
nodenames = {"default:chest", "default:npc_chest"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",default.chest_formspec)
end,
})
local function has_locked_chest_privilege(meta, player) local function has_locked_chest_privilege(meta, player)
if meta ~= nil then if meta ~= nil then

View File

@ -216,13 +216,10 @@ end
adventuretest.register_pl_hook(default.player_globalstep,0) adventuretest.register_pl_hook(default.player_globalstep,0)
if minetest.register_on_punchplayer ~= nil then if minetest.register_on_punchplayer ~= nil then
local enable_blood = adventuretest.blood
local texture_blood_cry = "mobs_blood_blue.png"
if enable_blood then texture_blood_cry = "mobs_blood.png" end
minetest.register_on_punchplayer( function(player, hitter, time_from_last_punch, tool_capabilities, dir) minetest.register_on_punchplayer( function(player, hitter, time_from_last_punch, tool_capabilities, dir)
local name = player:get_player_name() local name = player:get_player_name()
process_weapon(hitter,time_from_last_punch,tool_capabilities) process_weapon(hitter,time_from_last_punch,tool_capabilities)
blood_particles(player:getpos(),0.5,27,texture_blood_cry) blood_particles(player:getpos(),0.5,27,"mobs_blood.png")
if player_anim[name] == "lay" or player_anim[name] == "sit" then if player_anim[name] == "lay" or player_anim[name] == "sit" then
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}) player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
local sleep_hud = pd.get(name,"sleep_hud") local sleep_hud = pd.get(name,"sleep_hud")

View File

@ -371,11 +371,7 @@ function doors.register(name, def)
end end
def.after_dig_node = function(pos, node, meta, digger) def.after_dig_node = function(pos, node, meta, digger)
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
if adventuretest.is_50 then nodeupdate({x = pos.x, y = pos.y + 1, z = pos.z})
minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z})
else
nodeupdate({x = pos.x, y = pos.y + 1, z = pos.z})
end
end end
def.can_dig = function(pos, player) def.can_dig = function(pos, player)
return can_dig(pos, player) return can_dig(pos, player)

View File

@ -239,11 +239,7 @@ else
local p = minetest.find_node_near(p0, 1, {"group:flammable"}) local p = minetest.find_node_near(p0, 1, {"group:flammable"})
if p then if p then
minetest.remove_node(p) minetest.remove_node(p)
if adventuretest.is_50 then nodeupdate(p)
minetest.check_for_falling(p)
else
nodeupdate(p)
end
end end
end end
end, end,

View File

@ -2,9 +2,8 @@ local hb = {}
local scale = tonumber(core.setting_get("hud_scaling")) or 1 local scale = tonumber(core.setting_get("hud_scaling")) or 1
local function update_wheel(player) local function update_wheel(player)
local name = player:get_player_name() local name = player:get_player_name()
if not player or not name or not player:is_player() then if not player or not name then
return return
end end
@ -170,9 +169,6 @@ minetest.register_on_joinplayer(function(player)
end) end)
local function update_wrapper(a, b, player) local function update_wrapper(a, b, player)
if not player or not player:is_player() then
return
end
local name = player:get_player_name() local name = player:get_player_name()
if not name then if not name then
return return

View File

@ -1,9 +1,5 @@
mobs = {} mobs = {}
local enable_blood = adventuretest.blood
local texture_blood_cry = "mobs_blood_blue.png"
if enable_blood then texture_blood_dry = "mobs_blood.png" end
dofile(minetest.get_modpath("mobs").."/step.lua") dofile(minetest.get_modpath("mobs").."/step.lua")
mobs.mob_list = { npc={}, barbarian={}, monster={}, animal={}, npc_special={}} mobs.mob_list = { npc={}, barbarian={}, monster={}, animal={}, npc_special={}}
@ -62,7 +58,7 @@ function mobs:register_mob(name, def)
knock_back = def.knock_back or 3, knock_back = def.knock_back or 3,
blood_offset = def.blood_offset or 0, blood_offset = def.blood_offset or 0,
blood_amount = def.blood_amount or 15, blood_amount = def.blood_amount or 15,
blood_texture = texture_blood_cry, blood_texture = def.blood_texture or "mobs_blood.png",
rewards = def.rewards or nil, rewards = def.rewards or nil,
stationary = def.stationary or false, stationary = def.stationary or false,
activity_level = def.activity_level or 10, activity_level = def.activity_level or 10,
@ -638,14 +634,7 @@ end
function mobs:face_pos(self,pos) function mobs:face_pos(self,pos)
local s = self.object:getpos() local s = self.object:getpos()
local vec = {x=pos.x-s.x, y=pos.y-s.y, z=pos.z-s.z} local vec = {x=pos.x-s.x, y=pos.y-s.y, z=pos.z-s.z}
local yaw = 0 local yaw = math.atan(vec.z/vec.x)+math.pi/2
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then if self.drawtype == "side" then
yaw = yaw+(math.pi/2) yaw = yaw+(math.pi/2)
end end

View File

@ -144,14 +144,7 @@ function mobs.on_step(self,dtime)
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 = 0 local yaw = math.atan(vec.z/vec.x)+math.pi/2
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then if self.drawtype == "side" then
yaw = yaw+(math.pi/2) yaw = yaw+(math.pi/2)
end end
@ -230,13 +223,7 @@ function mobs.on_step(self,dtime)
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}
if vec.x ~= 0 then local yaw = math.atan(vec.z/vec.x)+math.pi/2
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then if self.drawtype == "side" then
yaw = yaw+(math.pi/2) yaw = yaw+(math.pi/2)
end end
@ -358,13 +345,7 @@ function mobs.on_step(self,dtime)
self.v_start = false self.v_start = false
else else
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}
if vec.x ~= 0 then local yaw = math.atan(vec.z/vec.x)+math.pi/2
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then if self.drawtype == "side" then
yaw = yaw+(math.pi/2) yaw = yaw+(math.pi/2)
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -3,12 +3,8 @@ quests.chest = {}
quests.chest.go = function(npc,player) quests.chest.go = function(npc,player)
local inv = player:get_inventory() local inv = player:get_inventory()
local pos = npc.object:getpos() local pos = npc.object:getpos()
if (inv:contains_item("main","farming_plus:flour") or inv:contains_item("main","food:flour")) and inv:contains_item("main","food:bowl") then if inv:contains_item("main","farming_plus:flour") and inv:contains_item("main","food:bowl") then
if inv:contains_item("main","farming_plus:flour") then inv:remove_item("main","farming_plus:flour")
inv:remove_item("main","farming_plus:flour")
else
inv:remove_item("main","food:flour")
end
inv:remove_item("main","food:bowl") inv:remove_item("main","food:bowl")
chat.local_chat(pos,"'Thank you very much, take this as a token of my appreciation!'",6) chat.local_chat(pos,"'Thank you very much, take this as a token of my appreciation!'",6)
local lp = player:getpos() local lp = player:getpos()

View File

@ -63,7 +63,7 @@ function skills.add_exp(name, exp)
l.exp = l.exp + exp l.exp = l.exp + exp
local next_level = ((l.level^2) * 50) local next_level = ((l.level^2) * 50)
while l.exp >= next_level do if l.exp >= next_level then
l.level = l.level + 1 l.level = l.level + 1
l.exp = l.exp - next_level l.exp = l.exp - next_level
minetest.chat_send_player(name,"You have gained a level! You are now level "..tostring(l.level)) minetest.chat_send_player(name,"You have gained a level! You are now level "..tostring(l.level))

View File

@ -89,51 +89,21 @@ local function inventory_set(player, size)
end end
local function on_craft(itemstack,player,old_craftgrid,craft_inv) local function on_craft(itemstack,player,old_craftgrid,craft_inv)
if itemstack:get_definition().skill ~= nil then
local name = player:get_player_name() local name = player:get_player_name()
if not name then return nil end local probability = skills.get_probability(name,SKILL_CRAFTING,itemstack:get_definition().skill)
local rangeLow = ( probability - 10 ) / 100
local craftItemDef = itemstack:get_definition() probability = probability / 100
if not craftItemDef then return nil end local wear = math.floor(50000 - ( 50000 * math.random(rangeLow,probability) ))
itemstack:add_wear(wear)
local craftItemSkill = craftItemDef.skill local i = skills.add_skill_exp(name,SKILL_CRAFTING,1)
if not craftItemSkill then return nil end local ii = skills.add_skill_exp(name,itemstack:get_definition().skill,1)
if i or ii then
if craftItemDef.type == "tool" then
local isSameItem = true
local itemCount = 0
local craftedItemName = craftItemDef.name
for _,recipeStack in ipairs(old_craftgrid) do
local recipeItemName = recipeStack:get_name()
if recipeItemName ~= "" then
itemCount = itemCount + 1
if itemCount > 2 then break end
if recipeItemName ~= craftedItemName then
isSameItem = false
break
end
end
end
if isSameItem and itemCount == 2 then
-- Yes we can ... repair
return nil
end
end
local probability = skills.get_probability(name, SKILL_CRAFTING, craftItemSkill)
local rangeLow = math.max(( probability - 10 ) / 100, 0.0)
probability = probability / 100
local wear = math.floor(50000 - ( 50000 * math.random(rangeLow,probability) ))
itemstack:add_wear(wear)
local craftItemDefw = itemstack:get_definition()
local craftItemSkillw = craftItemDefw.skill
-- local i = skills.add_skill_exp(name,SKILL_CRAFTING,1)
local ii = skills.add_skill_exp(name,craftItemSkillw,1)
if ii then
minetest.chat_send_player(name,"Your skills are increasing!") minetest.chat_send_player(name,"Your skills are increasing!")
end end
return itemstack return itemstack
end
return nil
end end
minetest.register_on_craft(on_craft) minetest.register_on_craft(on_craft)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 KiB