This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lewisholcombe's profile picture

Whats wrong with this program?

Started by lewisholcombe, 09 March 2013 - 12:46 PM
lewisholcombe #1
Posted 09 March 2013 - 01:46 PM
So basically when i run this program it returns "bit:40: bad argument : double expected, got nil"
I thought it ment i had 2 of the same colors but i don't.
If you want to see what the program is for go to my other topic: TOPIC
Heres the code

mon=peripheral.wrap("back")
mon.clear()
mon.setCursorPos(1,1)
mon.setTextScale(3)
print"Coal Generators: "
print"Geothermal Generators: "
print"Wind Mills: "
print"Water Mills: "
print"Solar Panels: "
print"HV Solar Arrays: "
print"MV Solar Arrays: "
print"LV Solar Arrays: "
while true do
	mon.setCursorPos(1,1)
	mon.setTextScale(3)
	os.pullEvent("redstone")
	local rsnpt = rs.getBundledInput("right")
	print("Coal Generators:"..(colors.test(rsnpt,colors.grey) and " On" or " Off"))
	print("Geothermal Generators: "..(colors.test(rsnpt,colors.pink) and " On" or " Off"))
	print("Wind Mills: "..(colors.test(rsnpt,colors.lime) and " On" or " Off"))
	print("Water Mills: "..(colors.test(rsnpt,colors.yellow) and " On" or " Off"))
	print("Solar Panels: "..(colors.test(rsnpt,colors.cyan) and " On" or " Off"))
	print("HV Solar Arrays: "..(colors.test(rsnpt,colors.magenta) and " On" or " Off"))
	print("MV Solar Arrays: "..(colors.test(rsnpt,colors.orange) and " On" or " Off"))
	print("LV Solar Arrays: "..(colors.test(rsnpt,colors.white) and " On" or " Off"))
end
(update) I have tried all different colours so its not that.
(update) I have copied it into pastebin for you guys http://pastebin.com/isUZgV40
lewisholcombe #2
Posted 09 March 2013 - 01:57 PM
Update
Just did it with different colors and had no luck still
Wing #3
Posted 09 March 2013 - 02:30 PM
ummm, I don't see why you only have
os.pullEvent("redstone") alone,
atleast add

while true do
	    mon.setCursorPos(1,1)
	    mon.setTextScale(3)
	    local sEvent = os.pullEvent("redstone")
	    if (sEvent == "redstone") then
	    local rsnpt = rs.getBundledInput("right")
	    print("Coal Generators:"..(colors.test(rsnpt,colors.grey) and " On" or " Off"))
	    print("Geothermal Generators: "..(colors.test(rsnpt,colors.pink) and " On" or " Off"))
	    print("Wind Mills: "..(colors.test(rsnpt,colors.lime) and " On" or " Off"))
	    print("Water Mills: "..(colors.test(rsnpt,colors.yellow) and " On" or " Off"))
	    print("Solar Panels: "..(colors.test(rsnpt,colors.cyan) and " On" or " Off"))
	    print("HV Solar Arrays: "..(colors.test(rsnpt,colors.magenta) and " On" or " Off"))
	    print("MV Solar Arrays: "..(colors.test(rsnpt,colors.orange) and " On" or " Off"))
	    print("LV Solar Arrays: "..(colors.test(rsnpt,colors.white) and " On" or " Off"))
	    end
end

That's just me though
Mailmanq! #4
Posted 09 March 2013 - 02:45 PM
ummm, I don't see why you only have
os.pullEvent("redstone") alone,
atleast add

while true do
		mon.setCursorPos(1,1)
		mon.setTextScale(3)
		local sEvent = os.pullEvent("redstone")
		if (sEvent == "redstone") then
		local rsnpt = rs.getBundledInput("right")
		print("Coal Generators:"..(colors.test(rsnpt,colors.grey) and " On" or " Off"))
		print("Geothermal Generators: "..(colors.test(rsnpt,colors.pink) and " On" or " Off"))
		print("Wind Mills: "..(colors.test(rsnpt,colors.lime) and " On" or " Off"))
		print("Water Mills: "..(colors.test(rsnpt,colors.yellow) and " On" or " Off"))
		print("Solar Panels: "..(colors.test(rsnpt,colors.cyan) and " On" or " Off"))
		print("HV Solar Arrays: "..(colors.test(rsnpt,colors.magenta) and " On" or " Off"))
		print("MV Solar Arrays: "..(colors.test(rsnpt,colors.orange) and " On" or " Off"))
		print("LV Solar Arrays: "..(colors.test(rsnpt,colors.white) and " On" or " Off"))
		end
end

That's just me though

If it pulls the event of redstone, that is the only event, why bother checking it, he is just waiting for a redstone signal
3LiD #5
Posted 09 March 2013 - 03:46 PM
I'm writting some code for you that will update automatically.
3LiD #6
Posted 09 March 2013 - 04:27 PM
Im sorry but I am a littlee busy today… I will post the code latter on.

EDIT: I have the code but I see you worked it… Nevermind
ChunLing #7
Posted 09 March 2013 - 05:46 PM
colors.grey is nil. The value you want is colors.gray (with an "a") or colours.grey (British spelling).
lewisholcombe #8
Posted 09 March 2013 - 08:40 PM
colors.grey is nil. The value you want is colors.gray (with an "a") or colours.grey (British spelling).
You life saver. Us stupid British ;)/> thanks
theoriginalbit #9
Posted 09 March 2013 - 08:44 PM
You life saver. Us stupid British ;)/> thanks
Its actually more of 'stupid Americans', if they didn't decide they couldn't speak the same english as the rest of the world, the whole world would use 'colours.grey'
ChunLing #10
Posted 09 March 2013 - 09:11 PM
I make the colors.grey mistake all the time, and I don't even use bundled cable…like, ever. So I'm pretty conscious of it.
theoriginalbit #11
Posted 09 March 2013 - 09:19 PM
I make the colors.grey mistake all the time, and I don't even use bundled cable…like, ever. So I'm pretty conscious of it.
yeh I make it heaps too, I can never remember which is American and which is British spelling. and the Sublime Text 2 plugin that GravityScore made doesn't help either. he needs to add the conditions :P/>
3LiD #12
Posted 09 March 2013 - 09:45 PM
I have coded it but I see you worked it out… Nevermind
lewisholcombe #13
Posted 09 March 2013 - 10:57 PM
I have coded it but I see you worked it out… Nevermind
I al still very interested in your code for my main computer at spawn on my server.
3LiD #14
Posted 10 March 2013 - 12:46 AM
Here is the code I would use… The only way to leave the program is to hold CTRL + R… It will update when a redstone inout updates.. YOu can change the scale and the background color. Sorry for the wait.

[spoiler]

local monitor = peripheral.wrap("left")
term.redirect(monitor)
monitor.setTextScale(1)
local m1 = "Coal Generator: "
local m2 = "Geothermal Generators: "
local m3 = "Wind Mills: "
local m4 = "Water Mills: "
local m5 = "Solar Panels: "
local m6 = "HV Solar Arrays: "
local m7 = "MV Solar Arrays: "
local m8 = "LV Solar Arrays: "
local ONLINE = "ONLINE"
while true do
term.setBackgroundColor(colors.blue)
term.setCursorPos(1, 1)
term.clear()
rsin = rs.getBundledInput("right")
print()
print("			  GENERATOR	  STATUS")
print()
print("		 " .. m1 .. "    " .. (colors.test(rsin, colors.gray) and ONLINE or "OFFLINE"))
print("  " .. m2 .. "    " .. (colors.test(rsin, colors.pink) and ONLINE or "OFFLINE"))
print("			 " .. m3 .. "    " .. (colors.test(rsin, colors.lime) and ONLINE or "OFFLINE"))
print("		    " .. m4 .. "    " .. (colors.test(rsin, colors.yellow) and ONLINE or "OFFLINE"))
print("		   " .. m5 .. "    " .. (colors.test(rsin, colors.cyan) and ONLINE or "OFFLINE"))
print("	    " .. m6 .. "    " .. (colors.test(rsin, colors.magenta) and ONLINE or "OFFLINE"))
print("	    " .. m7 .. "    " .. (colors.test(rsin, colors.orange) and ONLINE or "OFFLINE"))
print("	    " .. m8 .. "    " .. (colors.test(rsin, colors.white) and ONLINE or "OFFLINE"))
os.pullEvent("redstone")
end




(I tested it)
lewisholcombe #15
Posted 11 March 2013 - 01:15 AM
Here is the code I would use… The only way to leave the program is to hold CTRL + R… It will update when a redstone inout updates.. YOu can change the scale and the background color. Sorry for the wait.

[spoiler]

local monitor = peripheral.wrap("left")
term.redirect(monitor)
monitor.setTextScale(1)
local m1 = "Coal Generator: "
local m2 = "Geothermal Generators: "
local m3 = "Wind Mills: "
local m4 = "Water Mills: "
local m5 = "Solar Panels: "
local m6 = "HV Solar Arrays: "
local m7 = "MV Solar Arrays: "
local m8 = "LV Solar Arrays: "
local ONLINE = "ONLINE"
while true do
term.setBackgroundColor(colors.blue)
term.setCursorPos(1, 1)
term.clear()
rsin = rs.getBundledInput("right")
print()
print("			  GENERATOR	  STATUS")
print()
print("		 " .. m1 .. "    " .. (colors.test(rsin, colors.gray) and ONLINE or "OFFLINE"))
print("  " .. m2 .. "    " .. (colors.test(rsin, colors.pink) and ONLINE or "OFFLINE"))
print("			 " .. m3 .. "    " .. (colors.test(rsin, colors.lime) and ONLINE or "OFFLINE"))
print("		    " .. m4 .. "    " .. (colors.test(rsin, colors.yellow) and ONLINE or "OFFLINE"))
print("		   " .. m5 .. "    " .. (colors.test(rsin, colors.cyan) and ONLINE or "OFFLINE"))
print("	    " .. m6 .. "    " .. (colors.test(rsin, colors.magenta) and ONLINE or "OFFLINE"))
print("	    " .. m7 .. "    " .. (colors.test(rsin, colors.orange) and ONLINE or "OFFLINE"))
print("	    " .. m8 .. "    " .. (colors.test(rsin, colors.white) and ONLINE or "OFFLINE"))
os.pullEvent("redstone")
end




(I tested it)

Wow! I'm going to copy this into pastebin now and use it at spawn! Thankyou very much!!! :)/>