- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSignReader.lua
More file actions
Latest commit
53 lines (47 loc) · 1.53 KB
/
Copy pathSignReader.lua
File metadata and controls
53 lines (47 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require("class")
localsides=require("sides")
SignReader=class("SignReader")
functionSignReader:ctor(sign)
self.s=sign
end
functionSignReader:countSigns()
localcnt=0
if(self:get(sides.north) ~=nil) thencnt=cnt+1end
if(self:get(sides.south) ~=nil) thencnt=cnt+1end
if(self:get(sides.east) ~=nil) thencnt=cnt+1end
if(self:get(sides.west) ~=nil) thencnt=cnt+1end
if(self:get(sides.up) ~=nil) thencnt=cnt+1end
if(self:get(sides.down) ~=nil) thencnt=cnt+1end
returncnt
end
functionSignReader:getFirstSignSide()
if(self:get(sides.north)~=nil) thenreturnsides.northend
if(self:get(sides.south)~=nil) thenreturnsides.southend
if(self:get(sides.east)~=nil) thenreturnsides.eastend
if(self:get(sides.west)~=nil) thenreturnsides.westend
if(self:get(sides.up)~=nil) thenreturnsides.upend
if(self:get(sides.down)~=nil) thenreturnsides.downend
return-1
end
functionSignReader:get(side)
if(side==nil) then-- Try Smart Choice
if(self:countSigns() ==1) then
returnself.s.getValue(self:getFirstSignSide())
else
returnnil-- Cannot choose
end
else
returnself.s.getValue(side)
end
end
functionSignReader:set(val,side)
if(side==nil) then-- Try Smart Choice
if(self:countSigns() ==1) then
returnself.s.setValue(self:getFirstSignSide(),val)
else
returnnil-- Cannot choose
end
else
returnself.s.setValue(side,val)
end
end