Code: Select all
--calcul = 97887
--*
activeButtons = true
--*
offset_num = 0
drast_combination_lock.script.setCombination(self.go.id,{33,31,32,32,31}, function() indus_biodome_moongate_door_security_2.door:open() end)
function rune_offset(amount)
offset_num = offset_num + amount
return offset_num
end
function makeControls(my, what, base, size, range, omit)
local isLever = what == "lever"
if size == nil then
if what == "lever" then
size = {3, 6}
else
size = {6, 6}
end
end
local area
local rows, cols = size[1], size[2]
if isLever then area = {.9, -.6, 1, -1}
else area = {1.1, -.7, 1, -1}
end
if range ~= nil then
for i = 1, 4 do
if range[i] ~= nil then
area[i] = range[i]
end
end
end
local drop = {}
if omit ~= nil then
for i = 1, # omit do
drop[tostring(omit[i])] = true
end
end
local r1, r2, c1, c2 = area[1], area[2], area[3], area[4]
if rows == 1 then rdiv = 1 else rdiv = rows - 1 end
if cols == 1 then cdiv = 1 else cdiv = cols - 1 end
local dr, dc = (r1 - r2) / rdiv, (c1 - c2) / cdiv
local i, k = self.go.facing % 2 * 2 + 1, (self.go.facing + 1) % 2 * 2 + 1
local ar, ac = getForward(self.go.facing)
if self.go.facing == 1 or self.go.facing == 2 then sign = 1
else sign = -1
end
local adj = 0.0001 * (ar - ac)
for row = 1, rows do
local r = r1 - (row - 1) * dr
for col = 1, cols do
if not drop[row..col] then
local c = c1 - (col - 1) * dc
local ctl = spawn(what, my.go.level, my.go.x, my.go.y, my.go.facing, my.go.elevation, base..row..col)
local vec = ctl:getWorldPosition()
vec[2] = vec[2] + r
vec[i] = vec[i] + c * sign
vec[k] = vec[k] - adj
ctl:setWorldPosition(vec)
if isLever then ctl.lever:addConnector("onToggle", my.go.id, "leverFlip")
else ctl.button:addConnector("onActivate", my.go.id, "buttonPress")
end
end
end
end
end
function buttonPress(my)
--*
if activeButtons then
--*
local pushed = tonumber(string.sub(my.go.id, string.len(my.go.id) - 1))
-- hudPrint("button pressed: "..pushed)
drast_combination_lock.script.buttonPress(self.go.id, pushed)
--*
end
--*
end
function leverFlip(my)
local lev = findEntity(my.go.id)
local flipped = tonumber(string.sub(my.go.id, string.len(my.go.id) - 1))
drast_combination_lock(self.go.id,pushed)
end
makeControls(self, "numpad_button", self.go.id .."_button_", {4, 3}, {.525, -.36, .315, -.315})
--*
function setActive(bool) --call with false, when you break/disable the door.
if type(bool) == "boolean" then
activeButtons = bool
end
activeButtons = false
end
--*