Skip to content

Instantly share code, notes, and snippets.

@SirEdvin
Created July 14, 2021 09:52
Show Gist options
  • Save SirEdvin/adde0b68b05962796db83bf1ef5ca2b5 to your computer and use it in GitHub Desktop.
Save SirEdvin/adde0b68b05962796db83bf1ef5ca2b5 to your computer and use it in GitHub Desktop.
realityForger = peripheral.wrap("left")
playerDetector = peripheral.wrap("right")
chatBox = peripheral.wrap("back")
local gateBlocks = {
{x=0, y=0, z=3},
{x=1, y=0, z=3},
{x=0, y=1, z=3},
{x=1, y=1, z=3},
}
local gateSurroundBlocks = {
{x=-1, y=0, z=3},
{x=2, y=0, z=3},
{x=-1, y=1, z=3},
{x=2, y=1, z=3},
{x=-1, y=2, z=3},
{x=2, y=2, z=3},
{x=0, y=2, z=3},
{x=1, y=2, z=3},
}
local function playerInArea()
pos = playerDetector.getPlayerPos("Dev")
if (pos.x ~= 4 and pos.x ~= 3) then
return false
end
if (pos.y ~= 56 and pos.x ~= 57) then
return false
end
if (pos.z ~= 15 and pos.z ~= 16 and pos.z ~= 17 and pos.z ~= 14 and pos.z ~= 18) then
return false
end
return true
end
local gateState = false
local function playOpenGateAnimation()
realityForger.forgeRealityPieces(gateBlocks, {block = "minecraft:barrel"})
sleep(1)
realityForger.forgeRealityPieces(gateBlocks, {invisible = true, playerPassable = true})
realityForger.forgeRealityPieces(gateSurroundBlocks, {block = "minecraft:barrel"})
end
local function playCloseGateAnimation()
realityForger.forgeRealityPieces(gateSurroundBlocks, {block = "minecraft:stone_bricks"})
realityForger.forgeRealityPieces(gateBlocks, {block = "minecraft:barrel", invisible = false, playerPassable = false})
sleep(1)
realityForger.forgeRealityPieces(gateBlocks, {block = "minecraft:stone_bricks"})
end
result, err = realityForger.forgeReality({block = "minecraft:stone_bricks"})
if (not result) then
print(err)
end
while true do
sleep(0.1)
if playerInArea() then
if not gateState then
pcall(chatBox.sendMessageToPlayer, "Welcome master, gate are opened for you", "Dev")
playOpenGateAnimation()
gateState = true
end
else
if gateState then
playCloseGateAnimation()
gateState = false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment