computercraft

I got a bios 367 error on Computercraft

谁说我不能喝 提交于 2020-01-17 14:36:27
问题 On my program for Computer craft that will be used in a control tower in my airport map, I got a message that looked like this: bios:367:[string "AirportCommand"]:15: syntax error Here is all my code please tell me if you see any errors: local Landing_open = true rednet.open("top") while true do id, message, distance = rednet.receive() if message == "Requesting Landing" and Landing_open == true and distance<500 then rednet.send(id, "Landing is granted. Please respond with Landing finished

How to terminate Lua script?

你离开我真会死。 提交于 2020-01-02 00:53:14
问题 How would I terminate a Lua script? Right now I'm having problems with exit(), and I don't know why. (This is more of a Minecraft ComputerCraft question, since it uses the APIs included.) Here is my code: while true do if turtle.detect() then if turtle.getItemCount(16) == 64 then exit() --here is where I get problems end turtle.dig() --digs block in front of it end end 回答1: As prapin's answer states, in Lua the function os.exit([code]) will terminate the execution of the host program. This,

Use table key inside same (anonymous) table

对着背影说爱祢 提交于 2019-12-31 03:21:31
问题 I want to use a key insde an anonymous table from within that same table, like so: loadstring( [[return { a = "One", b = a.." two" }]] ) From my perspective, this should return the following table: { a = "One", b = "One two" } However, it just returns nil . Is this possible to do, and how? 回答1: As the other answer said, you can't reference a key in a table that is being constructed, but you can use a variable to hold the value you want to reference several times: local a = "One" local t = { a

Use table key inside same (anonymous) table

帅比萌擦擦* 提交于 2019-12-31 03:21:06
问题 I want to use a key insde an anonymous table from within that same table, like so: loadstring( [[return { a = "One", b = a.." two" }]] ) From my perspective, this should return the following table: { a = "One", b = "One two" } However, it just returns nil . Is this possible to do, and how? 回答1: As the other answer said, you can't reference a key in a table that is being constructed, but you can use a variable to hold the value you want to reference several times: local a = "One" local t = { a

I need help for my lua program in computercraft

北城余情 提交于 2019-12-12 00:28:19
问题 I have been recently working on a project to make an airport computer that keeps planes from landing on each other. For some reason, every time I run my program, it gives me an error message. I have another program that also gets error messages, that prints all the incoming messages onto a monitor. Here is my code: Error message for program 1(this message only occurs after it receives a message: [startup:9: attempt to compare __le on nil and number] Error message for program 2: [monitor:2

Basic LUA problems

流过昼夜 提交于 2019-12-11 16:54:43
问题 I'm using ComputerCraft, a Minecraft mod that adds computers, monitors, modems and so on, which can be programmed using Lua scripts. http://www.computercraft.info/wiki/Main_Page While running my script I get this error: "bios:171: bad argument: string expected, got nil". I dont understand because it says line 171 even though my code doesn't exceed 30 lines.. Can somebody explain? monitor = peripheral.wrap("right") monitor.clear() monitor.setCursorPos(1, 1) monitor.setTextScale(1) monitor

Table with methods, how to handle/inspect them?

可紊 提交于 2019-12-11 12:09:28
问题 So without the context, I have a method that returns a table. Trying to print it out, it seems that the table mainly contains methods to be called. However not being very knowledgeable in LUA, i have no idea how to properly get some information about these methods i should call. I tried to get documentation from the creator of the thing, but there is none as far as i know. And since this is inside computercraft (minecraft mod) i don't have a lot of features to rely on either. So knowing only

How to terminate Lua script?

拜拜、爱过 提交于 2019-12-05 01:22:20
How would I terminate a Lua script? Right now I'm having problems with exit(), and I don't know why. (This is more of a Minecraft ComputerCraft question, since it uses the APIs included.) Here is my code: while true do if turtle.detect() then if turtle.getItemCount(16) == 64 then exit() --here is where I get problems end turtle.dig() --digs block in front of it end end As prapin's answer states, in Lua the function os.exit([code]) will terminate the execution of the host program. This, however, may not be what you're looking for, because calling os.exit will terminate not only your script, but