Raw code: pastebin
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Simulation Game Problems
Started by Ziriee, 26 October 2013 - 08:48 AMPosted 26 October 2013 - 10:48 AM
So, I am trying to make a simulation game, but I am having problems with some bugs that I can't figure out. Anyone care to check it out?
Raw code: pastebin
Raw code: pastebin
Posted 26 October 2013 - 10:53 AM
Are you getting an error?
Posted 26 October 2013 - 10:59 AM
Yes.
Posted 26 October 2013 - 11:03 AM
bios:155: bad argument: string expected, got nilAre you getting an error?
Posted 26 October 2013 - 11:37 AM
After a quick read-thru, I noticed a potential issue: "activecat" and "elen" used on lines 69 & 70 are never initialized.
Posted 26 October 2013 - 12:21 PM
You are correct, now it changes the background color, but crashes with the same error after that and doesn't print the thing I want it to print.After a quick read-thru, I noticed a potential issue: "activecat" and "elen" used on lines 69 & 70 are never initialized.
Posted 26 October 2013 - 01:49 PM
*bump*
Posted 27 October 2013 - 03:37 AM
The write command on line 69 is causing the error (if you add a .."" to the end of what you pass to those write functions, then they'll fail with more useful errors).
It wants to write categoriesn["char"]. This value is set by whatever the third parameter you pass to the addCategory() function is, but when you're calling that function you're only passing two parameters: hence categoriesn["char"] is always set to nil and that write statement fails.
It wants to write categoriesn["char"]. This value is set by whatever the third parameter you pass to the addCategory() function is, but when you're calling that function you're only passing two parameters: hence categoriesn["char"] is always set to nil and that write statement fails.
Posted 27 October 2013 - 08:26 AM
Thanks. A lot. it was indeed fail on my side with the addCategory()'s third parameter.The write command on line 69 is causing the error (if you add a .."" to the end of what you pass to those write functions, then they'll fail with more useful errors).
It wants to write categoriesn["char"]. This value is set by whatever the third parameter you pass to the addCategory() function is, but when you're calling that function you're only passing two parameters: hence categoriesn["char"] is always set to nil and that write statement fails.
Posted 27 October 2013 - 08:38 AM
It fixed it a bit, but now it crashes on powder:77: attempt to index ? (a nil value) but when I open lua and write categories[elements[map[1][7]]][map[1][7]]["gravity"] It normally says 1 D:Thanks. A lot. it was indeed fail on my side with the addCategory()'s third parameter.The write command on line 69 is causing the error (if you add a .."" to the end of what you pass to those write functions, then they'll fail with more useful errors).
It wants to write categoriesn["char"]. This value is set by whatever the third parameter you pass to the addCategory() function is, but when you're calling that function you're only passing two parameters: hence categoriesn["char"] is always set to nil and that write statement fails.
Posted 27 October 2013 - 10:40 AM
I think you should put this check around the whole checkFallDown() function:
if map[y][x] > 0 then
if map[y][x] > 0 then
Posted 27 October 2013 - 10:46 AM
Why do people go to all the effort of syntax highlighting manually……. use [code][/code] tags, you can type them manually or click the button in the formatting bar, it saves a lot of time over manually highlighting everything!if map[y][x] > 0 then
Posted 27 October 2013 - 11:13 AM
I copied it right out of his pastebin, apparently formatting and all!
Posted 27 October 2013 - 11:15 AM
See the little rubber on the top line, second from the left, that removes all formatting on the selected text.I copied it right out of his pastebin, apparently formatting and all!
Posted 27 October 2013 - 11:30 AM
Great! Now it works how it's supposed to! Hooray!I think you should put this check around the whole checkFallDown() function:
if map[y][x] > 0 then