- ComputerCraft | Programmable Computers for Minecraft
- → Doyle3694's Content
Doyle3694's Content
There have been 11 items by Doyle3694 (Search limited from 10-February 22)
#204894 Reading the 8th line
Posted by
Doyle3694
on 02 February 2015 - 12:07 AM
in
Ask a Pro
I would however suggest that you read the whole file into a table. Doesn't have any technical advantage, but for making the code easier to understand and modify it is king. It also doesn't give cancer to people like me with heavy self-diagnosed OCD.
#202424 Chopping off part of a string
Posted by
Doyle3694
on 07 January 2015 - 08:14 PM
in
Ask a Pro
Got it to work, thanks everyone!
Final code for reference and for lazy people from the future
Final code for reference and for lazy people from the future
t = all
sCurFolder = sCurFolder:match( "(.*)%..-" ) or ""
for key in sCurFolder:gmatch("[^%.]+") do
if not t[key] then break end
t = t[key]
end
curFolder = t
#202402 Chopping off part of a string
Posted by
Doyle3694
on 07 January 2015 - 06:05 PM
in
Ask a Pro
So I have a door control system with a filesystem like structure where different doors are adressed by an adress which coresponds to a table. I've got almost everything done except for being able to move up 1 level in the system, similar to typing ".." in a file system
What I want to do now is being able to from an adress remove 1 step when backspace is pressed, for example making "all.Doors.AE2" into "all.Doors". I know how os.pullEvent and all that stuff works, but the specific function to use to remove everything including and after the first period from the end is where im lost. Barely used any of the string functions before.
If full code is needed
http://pastebin.com/sEE5XhXz
What I want to do now is being able to from an adress remove 1 step when backspace is pressed, for example making "all.Doors.AE2" into "all.Doors". I know how os.pullEvent and all that stuff works, but the specific function to use to remove everything including and after the first period from the end is where im lost. Barely used any of the string functions before.
If full code is needed
http://pastebin.com/sEE5XhXz
#195395 Monitor & control program with touch button overrides
Posted by
Doyle3694
on 06 October 2014 - 03:36 PM
in
Ask a Pro
Thats why you can use a timer with os.pullEvent: http://computercraft...mer_%28event%29
But yes, the parallel API should be just fine for your needs
But yes, the parallel API should be just fine for your needs
#195393 Monitor & control program with touch button overrides
Posted by
Doyle3694
on 06 October 2014 - 03:28 PM
in
Ask a Pro
While I am not experienced with parallel API and that might be the best thing for this, you could have an os.pullEvent() with a timer so that every 0.25 seconds it will check, then run your engine code, then check, the run your engine code and so on. Then again, you should be able to just use
And then have it in the button code so that it returns if the button is pressed.
-- Code parallel.waitForAny(enginecode, buttoncode)
And then have it in the button code so that it returns if the button is pressed.
#195389 Help needed
Posted by
Doyle3694
on 06 October 2014 - 03:13 PM
in
Ask a Pro
Use ['code'] tags
Ill get to try fixing the problem, just need the code clear in front of me
shell.run("clear")
function checkforWalls()
x = 1
while true do
if walls[x][1] == wanttox and walls[x][2] == wanttoy then return false end
if walls[x] == nil then return true end
x = x + 1
end
end
function move()
wanttodir = math.random(1,4)
if wanttodir == 1 then wanttox = xpos wanttoy = ypos - 1 end
if wanttodir == 2 then wanttox = xpos wanttoy = ypos + 1 end
if wanttodir == 3 then wanttox = xpos - 1 wanttoy = ypos end
if wanttodir == 4 then wanttox = xpos + 1 wanttoy = ypos end
if checkforWalls() then
xpos = wanttox
ypos = wanttoy
end
end
function load()
shell.run(read())
end
function draw()
term.setBackgroundColor(colors.green)
term.clear()
term.setCursorPos(1,1)
x = 1
while true do
term.setBackgroundColor(colors.red)
term.setCursorPos(walls[x][1],walls[x][2])
term.write("X")
x = x + 1
if walls[x] == nil then break end
end
end
function drawBug()
term.setCursorPos(xpos,ypos)
term.setBackgroundColor(colors.blue)
term.write("#")
end
load()
while true do
term.setBackgroundColor(colors.black)
draw()
term.setBackgroundColor(colors.black)
drawBug()
term.setBackgroundColor(colors.black)
move()
sleep(0,5)
end
Ill get to try fixing the problem, just need the code clear in front of me
#173192 [1.62][SSP]turtle.craft() removed
Posted by
Doyle3694
on 13 April 2014 - 01:58 PM
in
Bugs
After using turtle.craft() A LOT of times(I have a turtle picking up water and crafting it into fresh water) I encountered that the command turtle.craft() completely removes itself, to the point that the only way of getting it back is by restarting the game. Restarting the turtle does not work. Possible causes for this is either it crafting alot of times or the fact that I went to the nether while it was going so it might have gotten unloaded while turtle.craft()ing.
Code:
EDIT: What I mean by it removing itself is that it returns "attempt to call nil"
Code:
while true do turtle.select(1) turtle.placeDown() turtle.craft() turtle.select(2) while not turtle.drop() do end end
EDIT: What I mean by it removing itself is that it returns "attempt to call nil"
- ComputerCraft | Programmable Computers for Minecraft
- → Doyle3694's Content


