summaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorJakub Vaněk <vanek.jakub4@seznam.cz>2016-03-04 04:45:18 +0100
committerest31 <MTest31@outlook.com>2016-03-25 10:54:33 +0100
commit228abc52bd29ebbf67e06f238c377689bafd9a22 (patch)
treec43656361967074f1d480a49499a8ce5a0814cf1 /src/mapnode.cpp
parent3a18c237bdb7215aca10a613a9e8da2efefc9f69 (diff)
downloadminetest-228abc52bd29ebbf67e06f238c377689bafd9a22.tar.gz
minetest-228abc52bd29ebbf67e06f238c377689bafd9a22.tar.bz2
minetest-228abc52bd29ebbf67e06f238c377689bafd9a22.zip
Translated using Weblate (Czech)
Currently translated at 54.1% (468 of 865 strings)
Diffstat (limited to 'src/mapnode.cpp')
0 files changed, 0 insertions, 0 deletions
class='lines'>
-- passive.lua
-- API to passive components, as described in passive_api.txt of advtrains_luaautomation
-- This has been moved to the advtrains core in turn with the interlocking system,
-- to prevent a dependency on luaautomation.

local deprecation_warned = {}

function advtrains.getstate(parpos, pnode)
	local pos
	if atlatc then
		pos = atlatc.pcnaming.resolve_pos(parpos)
	else
		pos = advtrains.round_vector_floor_y(parpos)
	end
	if type(pos)~="table" or (not pos.x or not pos.y or not pos.z) then
		debug.sethook()
		error("Invalid position supplied to getstate")
	end
	local node=pnode or advtrains.ndb.get_node(pos)
	local ndef=minetest.registered_nodes[node.name]
	local st
	if ndef and ndef.advtrains and ndef.advtrains.getstate then
		 st=ndef.advtrains.getstate
	elseif ndef and ndef.luaautomation and ndef.luaautomation.getstate then
		if not deprecation_warned[node.name] then
			minetest.log("warning", node.name.." uses deprecated definition of ATLATC functions in the 'luaautomation' field. Please move them to the 'advtrains' field!")
		end
		st=ndef.luaautomation.getstate
	else
		return nil
	end
	if type(st)=="function" then
		return st(pos, node)
	else
		return st
	end
end

function advtrains.setstate(parpos, newstate, pnode)
	local pos
	if atlatc then
		pos = atlatc.pcnaming.resolve_pos(parpos)
	else
		pos = advtrains.round_vector_floor_y(parpos)
	end
	if type(pos)~="table" or (not pos.x or not pos.y or not pos.z) then
		debug.sethook()
		error("Invalid position supplied to getstate")
	end
	local node=pnode or advtrains.ndb.get_node(pos)
	local ndef=minetest.registered_nodes[node.name]
	local st
	if ndef and ndef.advtrains and ndef.advtrains.setstate then
		 st=ndef.advtrains.setstate
	elseif ndef and ndef.luaautomation and ndef.luaautomation.setstate then
		if not deprecation_warned[node.name] then
			minetest.log("warning", node.name.." uses deprecated definition of ATLATC functions in the 'luaautomation' field. Please move them to the 'advtrains' field!")
		end
		st=ndef.luaautomation.setstate
	else
		return nil
	end
	
	if advtrains.get_train_at_pos(pos) then
		return false
	end
	
	if advtrains.interlocking and advtrains.interlocking.route.has_route_lock(minetest.pos_to_string(pos)) then
		return false
	end
	
	st(pos, node, newstate)
	return true