Jump to content




Block IDs for my game get mixed up.


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

#1 jerp2042

  • New Members
  • 2 posts

Posted 23 February 2013 - 01:59 PM

Title: Block IDs for my game get mixed up.

So I set up my game so it sets a block ID in a table in another table. It does this using:
database[x][y]
With database being the table.

I made it so the blocks write the IDs on themselves.
http://tinyurl.com/ccblockidhelp1
And I made it so whenever I click on a block it gets the ID of the block and reprints it.
But it never reprints the right ID.
http://tinyurl.com/ccblockidhelp2
Can some help me, tell me what I'm doing wrong or revamp the code or something. :(

Spoiler

I'm sorry I don't use comments much. That'll probably make it a whole lot easier on you guys...

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 23 February 2013 - 05:35 PM

Split into new topic.

#3 ChunLing

  • Members
  • 2,027 posts

Posted 23 February 2013 - 05:49 PM

You use table.insert() in your block function. This is unnecessary and will shift blocks about if it is called on an existing block (given that you pre-generate the array, that occurs every time you call it), just use: database[x][y] = id.

#4 jerp2042

  • New Members
  • 2 posts

Posted 24 February 2013 - 04:20 AM

Thanks for helping! It worked! :D





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users