summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-08-16 09:47:12 -0700
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-08-16 09:47:12 -0700
commitff7f9a353767517e343d8bc9f18c7c3693c64d1b (patch)
tree9a244f42e7af34f4640629d734793353b50adc64
parent6a184f2d669aed9101ee9f1fc13d2cb02a5fa94c (diff)
Changed pricing scheme
-rw-r--r--init.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 571cede..c3edc27 100644
--- a/init.lua
+++ b/init.lua
@@ -72,7 +72,7 @@ end
markers.calculate_area_price = function( pos1, pos2, playername )
local price = math.ceil(( math.abs( pos1.x - pos2.x )+1 )
- * ( math.abs( pos1.z - pos2.z )+1 ) * (0.27* 1/(0.1+0.01*math.sqrt(pos1.x*pos2.x +pos1.z*pos2.z))));
+ * ( math.abs( pos1.z - pos2.z )+1 ) * (0.07* markers.surrounding_areas(pos1,100)+0.031));
-- * math.ceil( ( math.abs( pos1.y - pos2.y )+1 )/10);
@@ -257,7 +257,23 @@ markers.get_box_from_markers = function(name)
return min_pos, max_pos
end --get_box_from_markers
-
+markers.surrounding_areas = function (ppos, r)
+ local id_list = {};
+ for id, area in pairs(areas.areas) do
+
+ if( not( area.parent )
+ -- ppos is always available
+ and( (area.pos1.x >= ppos.x-r and area.pos1.x <= ppos.x+r )
+ or(area.pos2.x >= ppos.x-r and area.pos2.x <= ppos.x+r ))
+ and( (area.pos1.y >= ppos.y-r and area.pos1.y <= ppos.y+r )
+ or(area.pos2.y >= ppos.y-r and area.pos2.y <= ppos.y+r ))
+ and( (area.pos1.z >= ppos.z-r and area.pos1.z <= ppos.z+r )
+ or(area.pos2.z >= ppos.z-r and area.pos2.z <= ppos.z+r ))) then
+ table.insert( id_list, id );
+ end
+ end
+ return #id_list
+end
markers.get_marker_formspec = function(player, pos, error_msg)
local formspec = "";