function DirectionCheck() dirName = {}<br> for i,v in pairs(gmcp.Room.Info.exits) do<br> dirName[#dirName+1]=i<br> end<br>randomWalk(true)<br>end <br>function randomWalk(escapeAttempt)<br> if escapeAttempt then<br> if dirName[1] ~= nil then<br> currentDir = dirName[math.random(1,table.size(dirName))] if currentDir ~= "x" then send(currentDir) else for i=1,#dirName do if dirName[i] == "x" then table.remove(dirName,i) end end escapeAttempt(true) end<br> else<br> echo("Oh no! We're trapped!")<br> return<br> end<br> end<br>end Trigger(exits blocked): for i=1,#dirName do if dirName[i] == currentDir then table.remove(dirName,i) end end randomWalk(true) <p></p>
(I use a function to do the echo part, this was just to make it more obvious what it does)
Looking for any suggestions on how to expand on this.
Edit: I'm capturing special exits with this(the "x") which I want to do, I'm just not sure yet what I want to do with the x. So I added a part to remove it for now.
Comments
You could extend it to try and walk if you're free, leap or tumble if not.