Posted 03 May 2013 - 12:11 AM
ok, I'm working on an "infinite maze" it's a crossroads of all four directions (N/S/E/W) with pressure plates at the end that teleports the player to the opposite end and records the "exit", so in theory, I could track the player's "exits" and make as complex of a maze as I want, or change it as often as I want.
I want to track 4 inputs (most recent last four) And, for example, if they are N, N, W, N, then that triggers a teleportation, while N, N, N, S does not.
I've set up my program to count the inputs, and if any input exceeds 4 it teleports the player back to the start and resets the counter.
I am using the rs.getInput() command to determine which "direction" the player moved, and I can fill the four slots (if var1 = null, var1 = rs.input, if var1 != null, than (var2, var3, var4) —- not actual code, obviously) but what do I do once all four inputs are full? How to I tell it to begin recycling? I can recycle #1 by saying "if var4 =! null, then (var1) but after that, if I start over the code will begin to conflict because it will look for a "null" slot and there wont be one…
So, basically, how do I set it up to continually update the "last 4 inputs"?
current (severely incomplete) code (wrapping command block as a peripheral on bottom):
Current thoughts:
(note: warp1/etc would be a function to set and execute a command block /tp command)
local pos1 = null
local pos2 = null
local pos3 = null
local pos4 = null
local GetDir = null
if rs.getInput() == "back" then GetDir == "S" end
if rs.getInput() == "right" then GetDir == "W" end
if rs.getInput() == "left" then GetDir == "E" end
if rs.getInput() == "front" then GetDir == "N" end
if pos1 = null then pos1 = GetDir end
if pos2 = null then pos2 = GetDir end
if pos3 = null then pos3 = GetDir end
if pos4 = null then pos4 = GetDir end
if pos4 ~= null then pos1 = GetDir end
if (pos1=N) and (pos2=N) and (pos3=W) and (pos4=S) then Warp1() sleep(1) end
if (pos1=W) and (pos2=N) and (pos3=N) and (pos4=E) then Warp2() sleep(1) end
if (pos1=S) and (pos2=S) and (pos3=W) and (pos4=S) then Warp3() sleep(1) end
Thoughts on how to impliment this and where to go from here?
I want to track 4 inputs (most recent last four) And, for example, if they are N, N, W, N, then that triggers a teleportation, while N, N, N, S does not.
I've set up my program to count the inputs, and if any input exceeds 4 it teleports the player back to the start and resets the counter.
I am using the rs.getInput() command to determine which "direction" the player moved, and I can fill the four slots (if var1 = null, var1 = rs.input, if var1 != null, than (var2, var3, var4) —- not actual code, obviously) but what do I do once all four inputs are full? How to I tell it to begin recycling? I can recycle #1 by saying "if var4 =! null, then (var1) but after that, if I start over the code will begin to conflict because it will look for a "null" slot and there wont be one…
So, basically, how do I set it up to continually update the "last 4 inputs"?
current (severely incomplete) code (wrapping command block as a peripheral on bottom):
local N = 0
local S = 0
local E = 0
local W = 0
local cblock = peripheral.wrap("bottom")
local redo = cblock.setCommand("/tp @p 263 63 -149") cblock.runCommand() N=0 S=0 E=0 W=0 sleep(1)
--back is S,
--front is N,
--right is W,
--left is E
while true do
if rs.getInput("back") == "true" then S = S + 1 end
if rs.getInput("front") == "true" then N = N + 1 end
if rs.getInput("right") == "true" then W = W + 1 end
if rs.getInput("left") == "true" then E = E + 1 end
if S == 4 then redo() end
if N == 4 then redo() end
if E == 4 then redo() end
if W == 4 then redo() end
end
Current thoughts:
(note: warp1/etc would be a function to set and execute a command block /tp command)
local pos1 = null
local pos2 = null
local pos3 = null
local pos4 = null
local GetDir = null
if rs.getInput() == "back" then GetDir == "S" end
if rs.getInput() == "right" then GetDir == "W" end
if rs.getInput() == "left" then GetDir == "E" end
if rs.getInput() == "front" then GetDir == "N" end
if pos1 = null then pos1 = GetDir end
if pos2 = null then pos2 = GetDir end
if pos3 = null then pos3 = GetDir end
if pos4 = null then pos4 = GetDir end
if pos4 ~= null then pos1 = GetDir end
if (pos1=N) and (pos2=N) and (pos3=W) and (pos4=S) then Warp1() sleep(1) end
if (pos1=W) and (pos2=N) and (pos3=N) and (pos4=E) then Warp2() sleep(1) end
if (pos1=S) and (pos2=S) and (pos3=W) and (pos4=S) then Warp3() sleep(1) end
Thoughts on how to impliment this and where to go from here?