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

Simulation Game Problems

Started by Ziriee, 26 October 2013 - 08:48 AM
Ziriee #1
Posted 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
Zudo #2
Posted 26 October 2013 - 10:53 AM
Are you getting an error?
Ziriee #3
Posted 26 October 2013 - 10:59 AM
Yes.
Ziriee #4
Posted 26 October 2013 - 11:03 AM
Are you getting an error?
bios:155: bad argument: string expected, got nil
sens #5
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.
Ziriee #6
Posted 26 October 2013 - 12:21 PM
After a quick read-thru, I noticed a potential issue: "activecat" and "elen" used on lines 69 & 70 are never initialized.
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.
Ziriee #7
Posted 26 October 2013 - 01:49 PM
*bump*
Bomb Bloke #8
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.
Ziriee #9
Posted 27 October 2013 - 08:26 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.
Thanks. A lot. it was indeed fail on my side with the addCategory()'s third parameter.
Ziriee #10
Posted 27 October 2013 - 08:38 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.
Thanks. A lot. it was indeed fail on my side with the addCategory()'s third parameter.
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:
sens #11
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
theoriginalbit #12
Posted 27 October 2013 - 10:46 AM
if map[y][x] > 0 then
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!
sens #13
Posted 27 October 2013 - 11:13 AM
I copied it right out of his pastebin, apparently formatting and all!
theoriginalbit #14
Posted 27 October 2013 - 11:15 AM
I copied it right out of his pastebin, apparently formatting and all!
See the little rubber on the top line, second from the left, that removes all formatting on the selected text.
Ziriee #15
Posted 27 October 2013 - 11:30 AM
I think you should put this check around the whole checkFallDown() function:

if map[y][x] > 0 then
Great! Now it works how it's supposed to! Hooray!