- ComputerCraft | Programmable Computers for Minecraft
- → crazyguymgd's Content
crazyguymgd's Content
There have been 139 items by crazyguymgd (Search limited from 30-March 23)
#71968 [Turtle][Programming] Trouble with a variable
Posted by crazyguymgd on 10 January 2013 - 12:05 PM in Ask a Pro
#125322 [miscPeripherals]help with the smart helmet
Posted by crazyguymgd on 10 June 2013 - 08:04 PM in Peripheral Help and Discussion
m = peripheral.wrap("side") m.send("smartHelmet","message")
#71974 [lua]If statement troubles?
Posted by crazyguymgd on 10 January 2013 - 12:15 PM in Ask a Pro
#71930 [Lua][Question] Storing Functions in a Table
Posted by crazyguymgd on 10 January 2013 - 11:23 AM in Ask a Pro
ChunLing, on 10 January 2013 - 11:01 AM, said:
Like:
funcName = read() if turtle[funcName] then turtle[funcName]() endThere, now I can use user input to decide which turtle function to call, cause they are all in a table (and indexed by strings).
Well that is incredibly useful for a project I'm working on
#72455 [lua][help]Making a timer (more detail in the description)
Posted by crazyguymgd on 11 January 2013 - 10:59 AM in Ask a Pro
#73991 [LUA][ERROR]Getting false " 'then' expected " error?
Posted by crazyguymgd on 13 January 2013 - 10:27 PM in Ask a Pro
#74287 [Lua][Error] startup:27: attempt to call nil
Posted by crazyguymgd on 14 January 2013 - 11:27 AM in Ask a Pro
#74682 [Lua][Error] startup:27: attempt to call nil
Posted by crazyguymgd on 15 January 2013 - 07:43 AM in Ask a Pro
#73947 [Lua][Error] startup:27: attempt to call nil
Posted by crazyguymgd on 13 January 2013 - 09:14 PM in Ask a Pro
And I just spent a little while trying to force the error with no luck so something else you are doing must be wrong.
Sorry I couldn't find the problem, just letting you know I tried.
#73999 [Lua][Error] I need help finding out the error im getting for this a* demo
Posted by crazyguymgd on 13 January 2013 - 10:49 PM in Ask a Pro
#74009 [Lua][Error] I need help finding out the error im getting for this a* demo
Posted by crazyguymgd on 13 January 2013 - 11:07 PM in Ask a Pro
[code]
81: for x = 1,h do -- for each cell do
82: cell[x] = {}
83: stringl = filel.readLine()
84: for y = 1,w do
85: cell[x][y] = {}
86: --calculate heuristic
87: dx = math.abs(ex - x)
88: dy = math.abs(ey - y)
89: h = dx + dy
90: cell[x][y].h = h-1
91: ce = stringl:sub(y,y)
92: cell[x][y].type = gettype(ce)
93: end
94: end
[/code]
edit - can't figure out formating with this copied and pasted. sorry all you formatting gods
#73960 [Lua][Error] I need help finding out the error im getting for this a* demo
Posted by crazyguymgd on 13 January 2013 - 09:32 PM in Ask a Pro
#74020 [Lua][Error] I need help finding out the error im getting for this a* demo
Posted by crazyguymgd on 13 January 2013 - 11:36 PM in Ask a Pro
basically if it doesn't do what you want it to do, you'll probably have to re-write it to properly fit the structure you want...
#73937 [Lua][Error] I need help finding out the error im getting for this a* demo
Posted by crazyguymgd on 13 January 2013 - 08:53 PM in Ask a Pro
columna1, on 13 January 2013 - 08:21 PM, said:
81: for y = 1,w do -- for each cell do 82: cell[y] = {} 83: stringl = filel.readLine() 84: for x = 1,h do 85: cell[x][y] = {} 86: --calculate heuristic 87: dx = math.abs(ex - x) 88: dy = math.abs(ey - y) 89: h = dx + dy 90: cell[x][y].h = h-1 91: ce = stringl:sub(y,y) 92: cell[x][y].type = gettype(ce) 93: end 94: end
would define cell[x] first then it would define
cell[x][y] as a table
so that i could use it almost as an object with a 2d identifier
Also if you want i could post the code without the lines numbered
and i have defined cell to as a table
cell[y] = {}, when y is 1, puts an empty table at cell[1].
then you go into the x loop.
when x = 1, cell[1][1] = {} works fine because you created that empty table at cell[1].
But the next time through the for loop, you try to access cell[2][1] which doesn't exist...
#73269 [Lua][Error] Bios:338 error?
Posted by crazyguymgd on 12 January 2013 - 06:11 PM in Ask a Pro
#73252 [Lua][Error] Bios:338 error?
Posted by crazyguymgd on 12 January 2013 - 05:50 PM in Ask a Pro
#71913 [Lua][Error]
Posted by crazyguymgd on 10 January 2013 - 11:09 AM in Ask a Pro
#71926 [lua] turtle compare statements not working as expected
Posted by crazyguymgd on 10 January 2013 - 11:20 AM in Ask a Pro
hopefully that's your only problem
#73246 [lua] strip mining automation complication
Posted by crazyguymgd on 12 January 2013 - 05:40 PM in Ask a Pro
Second tip, instead of
if false then ... end if true then ... endyou can simplify to
if true then ... else ... end
Then you can just add TheOiginalBITs suggestion and you'll have made some progress in the right direction.
#74587 [lua] script problem
Posted by crazyguymgd on 15 January 2013 - 05:06 AM in Ask a Pro
#72399 [lua] Need help writing a program
Posted by crazyguymgd on 11 January 2013 - 09:17 AM in Ask a Pro
#72326 [lua] Need help writing a program
Posted by crazyguymgd on 11 January 2013 - 05:43 AM in Ask a Pro
#71849 [lua] Need help writing a program
Posted by crazyguymgd on 10 January 2013 - 09:37 AM in Ask a Pro
#72393 [lua] Need help writing a program
Posted by crazyguymgd on 11 January 2013 - 09:03 AM in Ask a Pro
local loctable = {} local currline = 0 local pos = 1 local wire = 0 function readFile() term.clear() term.setCursorPos(1,1) local countlines = 1 file = io.open("power","r") for line in file:lines() do for name, active in string.gmatch(line, "(.+):(/>%w+)") do loctable[countlines] = {["name"] = name, ["active"] = active} end countlines = countlines + 1 end file:close() end readFile() function printMenu() term.setCursorPos(1,1) term.clear() for i = 1, #loctable do wire = redstone.getBundledOutput("bottom") if loctable[i].active == "Open" then term.setTextColor(colors.lime) wire = colors.combine(wire, 2^#loctable) else term.setTextColor(colors.red) wire=colors.subtract(wire, 2^#loctable) end redstone.setBundledOutput("bottom", wire) if i == pos then print(loctable[i].name.."="..loctable[i].active.."*") else print(loctable[i].name.."="..loctable[i].active) end end term.setTextColor(colors.white) end while true do printMenu() local event, a = os.pullEvent("key") if a == 200 and pos > 1 then pos = pos - 1 end if a == 208 and pos < 3 then pos = pos + 1 end if a == 28 then if loctable[pos].active == "Open" then loctable[pos].active = "Closed" else loctable[pos].active = "Open" end end end
#72382 [lua] Need help writing a program
Posted by crazyguymgd on 11 January 2013 - 08:45 AM in Ask a Pro
Every time you call printMenu(), you read from the file again, overwriting any data you may have changed if the enter key works, and reprint the old data. So you may be doing that part correctly but you're overwriting it every time through the loop.
- ComputerCraft | Programmable Computers for Minecraft
- → crazyguymgd's Content