Jump to content




Simulation Game Problems

game computer lua

  • You cannot reply to this topic
14 replies to this topic

#1 Ziriee

  • Members
  • 47 posts

Posted 26 October 2013 - 09: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

#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 26 October 2013 - 09:53 AM

Are you getting an error?

#3 Ziriee

  • Members
  • 47 posts

Posted 26 October 2013 - 09:59 AM

Yes.

#4 Ziriee

  • Members
  • 47 posts

Posted 26 October 2013 - 10:03 AM

View PostZudoHackz, on 26 October 2013 - 09:53 AM, said:

Are you getting an error?
bios:155: bad argument: string expected, got nil

#5 sens

  • Members
  • 49 posts
  • LocationFrance

Posted 26 October 2013 - 10:37 AM

After a quick read-thru, I noticed a potential issue: "activecat" and "elen" used on lines 69 & 70 are never initialized.

#6 Ziriee

  • Members
  • 47 posts

Posted 26 October 2013 - 11:21 AM

View Postsens, on 26 October 2013 - 10:37 AM, said:

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.

#7 Ziriee

  • Members
  • 47 posts

Posted 26 October 2013 - 12:49 PM

*bump*

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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[ i]["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[ i]["char"] is always set to nil and that write statement fails.

#9 Ziriee

  • Members
  • 47 posts

Posted 27 October 2013 - 08:26 AM

View PostBomb Bloke, on 27 October 2013 - 03:37 AM, said:

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[ i]["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[ i]["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.

#10 Ziriee

  • Members
  • 47 posts

Posted 27 October 2013 - 08:38 AM

View PostZiriee, on 27 October 2013 - 08:26 AM, said:

View PostBomb Bloke, on 27 October 2013 - 03:37 AM, said:

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[ i]["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[ i]["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:

#11 sens

  • Members
  • 49 posts
  • LocationFrance

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

#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 27 October 2013 - 10:46 AM

View Postsens, on 27 October 2013 - 10:40 AM, said:

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!

#13 sens

  • Members
  • 49 posts
  • LocationFrance

Posted 27 October 2013 - 11:13 AM

I copied it right out of his pastebin, apparently formatting and all!

#14 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 27 October 2013 - 11:15 AM

View Postsens, on 27 October 2013 - 11:13 AM, said:

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.

#15 Ziriee

  • Members
  • 47 posts

Posted 27 October 2013 - 11:30 AM

View Postsens, on 27 October 2013 - 10:40 AM, said:

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!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users