View difference between Paste ID: aweTnKEP and k2wVeWXz
SHOW: | | - or go back to the newest paste.
1
--Variables --
2
local mouseWidth = 0
3
local mouseHeight = 0
4
5
local currentDestination = "None"
6
local currentPlayer = "None"
7
8
local Turtle = 3
9
10-
--Setup sensor--
10+
11-
local sensor = peripheral.wrap('back')
11+
12
13-
local minX = -5 local maxX = 0
13+
14-
local minY = 0  local maxY = 10
14+
local monitor = peripheral.wrap("back")
15-
local minZ = -5 local maxZ = 0
15+
monitor.setBackgroundColor(colors.black)
16
monitor.clear()
17
18-
local monitor = peripheral.wrap("left")
18+
19
--Write first list of destinations
20
	monitor.setCursorPos(2,2)
21
	if currentDestination == "Tribble" then
22
		monitor.setBackgroundColor((colors.green))
23-
function setCurrentPlayername(name)
23+
24-
	if(name=="None") then
24+
25-
		currentPlayer="None"
25+
26-
		currentDestination="None"
26+
	monitor.write("  Tribble         ")
27-
		sendTurtleMessage("Stop")
27+
28
	monitor.setCursorPos(2,4)
29-
		
29+
	if currentDestination == "PietervBerkel" then
30-
		monitor.setCursorPos(2,2)
30+
31-
		monitor.setBackgroundColor((colors.blue))
31+
32-
		monitor.write(" No players detected ")
32+
33-
	elseif(name==currentPlayer) then
33+
34-
		-- Do nothing --
34+
	monitor.write("  PietervBerkel   ")
35
36-
		currentPlayer=name
36+
37-
		
37+
38-
		monitor.setCursorPos(2,2)
38+
	if currentDestination == "Razyr" then
39-
		monitor.setBackgroundColor((colors.blue))
39+
40-
		monitor.write(" Hello ")
40+
41-
		
41+
42-
		monitor.setCursorPos(9,2)
42+
43-
		monitor.setBackgroundColor((colors.blue))
43+
	monitor.write("  Razyr           ")
44-
		if(string.len(name) < 15) then
44+
45-
			monitor.write(" " .. EnlargeName(name,15))
45+
46
	if currentDestination == "GrooteMoeite" then
47-
			monitor.write(" " .. string.sub(name,0,11) .. ".. ")
47+
48-
		end
48+
49
		monitor.setBackgroundColor((colors.red))
50
	end
51
	monitor.write("  GrooteMoeite    ")
52
53
	monitor.setCursorPos(2,10)
54
	if currentDestination == "Louw" then
55-
	if currentDestination == "MachineRoom" then
55+
56
		else
57
		monitor.setBackgroundColor((colors.red))
58
	end
59
	monitor.write("  Louw            ")
60-
	monitor.write("  Machine Room         ")
60+
61
	monitor.setCursorPos(2,12)
62
	if currentDestination == "Ace_Of_Knaves" then
63-
	if currentDestination == "AppliedEnergistics" then
63+
64
		else
65
		monitor.setBackgroundColor((colors.red))
66
	end
67
	monitor.write("  Ace_Of_Knaves   ")
68-
	monitor.write("  Applied Energistics  ")
68+
69
	monitor.setCursorPos(2,14)
70
	if currentDestination == "None" then
71-
	if currentDestination == "Destination 3" then
71+
72
		else
73
		monitor.setBackgroundColor((colors.red))
74
	end
75
	monitor.write("  None           ")
76-
	monitor.write("  Destination 3  ")
76+
77
78
-- Perform clicked action --
79
function checkClickPosition()
80
	-- 1st Row --
81
	if(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 2) then
82
		currentDestination = "Tribble"
83
		setcurrentDestinationData()		
84
		sendTurtleMessage(1)
85
	-- 1st Row --
86
	elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 4) then
87
		currentDestination = "PietervBerkel"
88
		setcurrentDestinationData()		
89
		sendTurtleMessage(2)
90
	-- 1st Row --
91
	elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 6) then
92
		currentDestination = "Razyr"
93
		setcurrentDestinationData()		
94
		sendTurtleMessage(3)
95
	-- 2nd Row --
96
	elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 8) then
97
		currentDestination = "GrooteMoeite"
98-
	if(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 6) then
98+
99-
		currentDestination = "MachineRoom"
99+
100
	-- 3rd Row --
101
	elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 10) then
102
		currentDestination = "Louw"
103
		setcurrentDestinationData()	
104-
		currentDestination = "AppliedEnergistics"
104+
		sendTurtleMessage(5)		
105
	-- 4th Row --
106-
		sendTurtleMessage(2)	
106+
107
		currentDestination = "Ace_Of_Knaves"
108
		setcurrentDestinationData()	
109-
		currentDestination = "Destination 3"
109+
		sendTurtleMessage(6)	
110
	-- 5th Row --
111-
		sendTurtleMessage(3)		
111+
112
		currentDestination = "None"
113
		setcurrentDestinationData()
114
		sendTurtleMessage(7)
115
	end
116
117
	sleep(5)
118
	currentDestination = "None"
119
	setcurrentDestinationData()
120
end
121-
		sendTurtleMessage(5)
121+
122
-- Send message --
123
function sendTurtleMessage(Message)
124
	rednet.send(Turtle,Message)
125-
function EnlargeName(name,size)
125+
126-
	nameLength = string.len(name)
126+
127-
	
127+
128-
	if(nameLength < size) then
128+
129-
		local temp = name
129+
130-
		for variable = 0,size - nameLength,1 do
130+
131-
			temp = temp .. " "
131+
132-
		end
132+
133-
		return temp
133+
134
		mouseWidth = p2
135
		mouseHeight = p3
136
		checkClickPosition()
137
	end		
138
end
139-
	if(Message == "Stop") then
139+
140-
		rednet.broadcast(Message,"TravelhubTurtle")
140+
repeat
141
	monitorActivities()
142-
		rednet.broadcast(Message,"TravelhubTurtle")
142+
until event=="char" and p1==("x")