View difference between Paste ID: 204pPqQ7 and zhu3BfTF
SHOW: | | - or go back to the newest paste.
1-
trainWaitTime = 10
1+
os.loadAPI("ocs/apis/sensor")
2
mySensor = sensor.wrap("left")
3-
--Prints Texts on monitors and sets trains free
3+
4-
function monitorPainting()
4+
while true do
5-
	print("Monitorpainting wird gestartet....")
5+
	targets = mySensor.getTargets()
6-
	rednet.open("back")
6+
	player = false;
7
	for k, v in pairs( targets ) do
8-
	local monitors = nil
8+
		details = mySensor.getTargetDetails(k)
9-
	if os.getComputerLabel() == "Bahnhof1" then
9+
		if details ~= nil and details["IsPlayer"] ~= nil and details["IsPlayer"] then
10-
		monitors = {peripheral.wrap( "monitor_0" ),peripheral.wrap( "monitor_1" ),peripheral.wrap( "monitor_2" ),peripheral.wrap( "monitor_6" )}
10+
			pos = details["Position"];
11-
	elseif os.getComputerLabel() == "Bahnhof2" then
11+
			dist = math.sqrt(math.pow(pos["X"],2) + math.pow(pos["Y"],2) + math.pow(pos["Z"],2))
12-
		monitors = {peripheral.wrap( "monitor_3" ),peripheral.wrap( "monitor_4" ),peripheral.wrap( "monitor_7" ),peripheral.wrap( "monitor_8" )}
12+
			if dist <= 40 then
13
				player = true
14-
	
14+
15
		end
16-
			
16+
17-
	local zugPlan = {} 
17+
18-
	myApi.executeTableFunction(monitors, "setTextScale",0.7)
18+
	if player then
19-
	
19+
		redstone.setOutput("right", true)
20-
	while true do
20+
	else
21-
		local senderId, message, protocol = rednet.receive()
21+
		redstone.setOutput("right", false)
22-
		local targets = textutils.unserialize(message)
22+
23-
		
23+