Tic Tac Toe game, trying to use more than 9 choices.

I have tried everything I can think of, everything that I can guess, everything I can research.  I know it isn’t working.  I really need help with a solution rather than posts that what I am doing isn’t working.  I do know that. Is there anyone out there that can help Please?

Sorry Mark, but that’s how it works.  We respond the best we can to the posts you write.  

Sometimes folks feel generous enough to really dig in and help re-write a project, but often times we’re too busy so we post back help and hints instead.

What it really sounds like you need is  a partner, mentor, or contractor.  

Would it be of any value to you at all if someone posted code that could do this?:

  • Draw a bingo card with these attributes
    • 5x5 alternating color grid separated by lines
    • Free spot filled with circle
    • Other grid spots filled with numbers that you can define in code as a table.
    • each grid is a button that can be toggled to show it is selected
  • Includes logic to detect a BINGO and if so, to highlight the line and show a message. “BINGO”.
  • Includes a reset button to clear all selections and essentially restart the game.

Thank you so much for all of your help.  I really do appreciate it.  I can’t waste any more time on this.  I really truly do appreciate your help. 

First, you can’t do:

tableShuffle( t )

because you don’t have a table named “t”. Second of all, when people are helping you here, they are hand typing in examples that **should** work, but sometimes typos get in the way. It’s really important for you to learn how to debug your code. There is a typo in some provided code, but the answer is in your error message.

"main.lua35:attempt to call global 'tableShuffle' (a nil value) stack traceback:&nbsp;main.lua:35: in function '\_onPress' ?:in function '?' ?:in function '?' ?:in function \<?:190\>"

 

Look at your main.lua.

Go to line 35

You are calling a function named “tableShuffle”. 

Corona says it can’t find it (a nil value)

 

You need to ask yourself a question? Why is “tableShuffle” nil or non-existent? 

Then you need to look through your code and see why it can’t find a function named “tableShuffle”

 

If you do that, the answer is clear. You don’t have one named tableShuffle, but you do have one named shuffleTable. In this case, 

 

This code:

 

local function shuffleBingoBalls() tableShuffle(bingoBalls) end

probably should be

local function shuffleBingoBalls() shuffleTable(bingoBalls) end

Now order of code matters in Lua. This function must exist before you create your button. This code calls shuffleTable and references the table “bingoBalls”, so it has to exist **after** both of those items in your code.

 

Rob
 

Mark,

If you truly want to code and make games, don’t give up.  It will make you pull your hair out alot of times.  Take a break for a day and give it another go.

If you don’t mind me saying, learning from scratch as you apparently are doing, is the way I did it - and it took a lot of time and a lot of frustration… and I am still not at the level of Roaming Gamer and Nick_Sherman and Rob Miracle to just name a few… but for me it was worth it.

If I can add; I had to take apart sample code over and over and over… and go thru countless tutorials - changing code in those tutorials to get a feel of what was actually happening…  it is time consuming and aggravating; especially when you are anxious to get to making something real.  I also started with the simplest of sample code.  Simple tic tac toe type game. And moved up from there.

Just a few last points:

  1. As Roaming Gamer mentioned ‘scope’ is the likely issue to the last error… very common for someone new to coding.  Look at as many tutorials as you can find that strictly talk about ‘scope’.

  2. It is not an easy; and one of the most common mistakes I made and I see others make, is not reading the error message completely and misspelling the name of the variable or functions and not matching ‘case’.

I hope you give it another try after a short break… that is if you truly want to code games.  Corona is a great tool for doing that.

Best of luck

Bob

As advised before Mark, you cannot code without learning to code. Countless hours of frustration you have experienced would have been avoided by learning the basics. And probably saved you hours of trial and error.

For example, the whole table named ‘t’ mix up.

When an object is used in a function, it is often given a different name than that of the object provided. We can pass any table to shuffleTable and all these could have different names.

While it is being processed in that function, it will be called ‘t’. It’s kind of a nickname, a handle. ‘t’ is used because it’s easy to type over and over and short for table.

A more accurate name might be ‘tableThatIsToBeShuffled’. However, in this small function, an abbreviation is fine. If we had a global variable called ‘t’ however, we’d come back to it 6 months later and have no idea what it stood for.

Once that shuffleTable function is over, the table must still be referred to by its original name. The nickname, or reference, ‘t’ no longer exists.

https://www.youtube.com/watch?v=ZugCYGLF12Q&feature=youtu.be

https://github.com/roaminggamer/RG_FreeStuff/raw/master/gamesIn250/002_bingoCard.zip