1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-05 10:00:26 +01:00

passage de variables global en local

passage de variables global en local
This commit is contained in:
crabman77 2015-01-14 17:33:46 +01:00 committed by LeMagnesium
parent 7e58605553
commit 5fb7a6e662
6 changed files with 20 additions and 20 deletions

View File

@ -236,15 +236,15 @@ local is_daytime = function()
end
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.find_nodes_in_area(minp, maxp, node_name)
local minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
local maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
local nodes = minetest.find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local nodes_in_coords = function(minp, maxp, node_name)
nodes = minetest.find_nodes_in_area(minp, maxp, node_name)
local nodes = minetest.find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
@ -394,11 +394,11 @@ local get_ambience = function(player)
-- minetest.chat_send_all("n3uf:" ..node_3_under_feet)
--
local air_or_ignore = {air=true,ignore=true}
minp = {x=pos.x-3,y=pos.y-4, z=pos.z-3}
maxp = {x=pos.x+3,y=pos.y-1, z=pos.z+3}
local minp = {x=pos.x-3,y=pos.y-4, z=pos.z-3}
local maxp = {x=pos.x+3,y=pos.y-1, z=pos.z+3}
local air_under_player = nodes_in_coords(minp, maxp, "air")
local ignore_under_player = nodes_in_coords(minp, maxp, "ignore")
air_plus_ignore_under = air_under_player + ignore_under_player
local air_plus_ignore_under = air_under_player + ignore_under_player
-- minetest.chat_send_all("airUnder:" ..air_under_player)
-- minetest.chat_send_all("ignoreUnder:" ..ignore_under_player)
-- minetest.chat_send_all("a+i:" ..air_plus_ignore_under)
@ -448,7 +448,7 @@ local get_ambience = function(player)
end
desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
local desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
--minetest.chat_send_all("desertcount: " .. desert_in_range .. ",".. pos.y )
if desert_in_range >250 then
if music then

View File

@ -1,6 +1,6 @@
function spawn_falling_node(p, node, owners)
obj = minetest.add_entity(p, "__builtin:falling_node")
local obj = minetest.add_entity(p, "__builtin:falling_node")
obj:get_luaentity():set_node(node)
obj:get_luaentity():set_owner(owners)
end
@ -52,10 +52,10 @@ end
--
function nodeupdate_single(p, delay)
n = minetest.get_node(p)
local n = minetest.get_node(p)
if minetest.get_item_group(n.name, "falling_node") ~= 0 then
p_bottom = {x=p.x, y=p.y-1, z=p.z}
n_bottom = minetest.get_node(p_bottom)
local p_bottom = {x=p.x, y=p.y-1, z=p.z}
local n_bottom = minetest.get_node(p_bottom)
-- Note: walkable is in the node definition, not in item groups
if minetest.registered_nodes[n_bottom.name] and
(minetest.get_item_group(n.name, "float") == 0 or

View File

@ -29,7 +29,7 @@ minetest.register_entity(":__builtin:falling_node", {
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
local prop = {
is_visible = true,
textures = {node.name},
}

View File

@ -30,7 +30,7 @@ minetest.register_entity(":__builtin:item", {
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
local prop = {
is_visible = true,
visual = "sprite",
textures = {"unknown_item.png"}

View File

@ -19,8 +19,8 @@ function hp_bar:on_step(dtime)
self.object:remove()
return
end
hp = wielder:get_hp()
breath = wielder:get_breath()
local hp = wielder:get_hp()
local breath = wielder:get_breath()
self.object:set_properties({textures = {"health_" .. tostring(hp) .. ".png^breath_" .. tostring(breath) .. ".png"}})
end

View File

@ -3,13 +3,13 @@
minetest.register_globalstep(function(dtime)
local players = minetest.get_connected_players()
for i,player in ipairs(players) do
target = lavatemple.mapgen_data.pos;
local target = lavatemple.mapgen_data.pos;
if not target then return end
pos = player:getpos()
dir = player:get_look_yaw()
local pos = player:getpos()
local dir = player:get_look_yaw()
local angle_north = math.deg(math.atan2(target.x - pos.x, target.z - pos.z))
if angle_north < 0 then angle_north = angle_north + 360 end
angle_dir = 90 - math.deg(dir)
local angle_dir = 90 - math.deg(dir)
local angle_relative = (angle_north - angle_dir) % 360
local compass_image = math.floor((angle_relative/30) + 0.5)%12