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

Do you mean, the TV channel will televise the choices and people will be able to play along on their devices?

If so, that is a not insignificant project and will require: 

  1. Game Server - To choose numbers and allow users to connect and play along
  2. Some way to display game server choices on a screen or other device so you can broadcast that.
  3. app(s) in Android and/or iOS stores.  This app will need to implement multi-player code if you want players to be able to play along with the server.

#1 Will cost money and/or significant experience/knowledge.

#2 can be done w/ Corona but it will require some expertise.

#3 can be done with Corona for a low cost, and medium effort, but you’ll have to know quite a lot. 

What I said for #2 and #3 are true for all game engines and sdk that I am familiar with.  i.e. While the solutions may vary, the fundamentals stay the same.

I don’t think the design is as complex as that Ed, I think it’s all local to the device, just watching along with the channel, with the ability to e-mail in a screenshot and phone number if the numbers on your device match those drawn on TV.

Even so, not a beginner’s project and requiring a certain amount of honesty on behalf of the viewers…

You can’t code apps without learning how to code. That has nothing to do with Corona. Whatever framework you had chosen, you still need to learn what a variable is, how to break down problems into coding logic, and how to read API documents. 

That takes time. Time you don’t have. If you don’t have the time, why should anyone else? 

Rob is a Corona employee, but he is paid to assist, not teach you the basics of coding. The rest of us volunteer time freely to help people who are in the position we were once in ourselves, with the understanding that we expect them to put in the same effort we did when we were learning. Some offer coding services, but RoamingGamer gives up tens of thousands of pounds worth of free time and code every year. He’s certainly not here to make a quick buck.

I learnt C64 basic when I was 8 without a manual. There was no Internet. One day one of the games I was playing crashed and I found I could look at the code, and I was away. You have a billion pages on Google related to programming, all the Corona API docs, tutorials, example code, all the resources necessary to code anything you can imagine. If you don’t have the time, that’s unfortunate, but your expectations of the forum are completely unrealistic.

No-one from Corona is trying to get money from you. The fact we get this incredible game engine for free is amazing in itself. 10-15 years ago, you’d have been paying $10,000 a year per seat for a tool with this power.

@mark036,

I can see you’re frustrated and I’m sorry that is the case.

However, I think you’ve got some things mixed up here.

  1. So far, with the exception of Rob, everyone who has answered you is not staff.  Put another way, we are all just folks (Corona users) taking time out from our money making working hours to try to give some help or pointers to folks in the forums.

  2. You’re not a client.  You’re a user.  There is a big difference.  A client is a person who has paid for a service.  I think you know this, but are just angry at this time.  Again, I’m sorry if you are frustrated.

  3. All of the things you listed are true:

  • Easy-to-learn & powerful
  • … yada yada
  • More than 500,000 developers and an
  • active, helpful forum

I think perhaps you’re sticking on the last bit.  The forums activity varies by may factors, but it is fair to call it active.  I rarely see a post go unanswered.  i.e. without response. 

 

Also, I feel helpful.  I’ve posted almost 7000 times since 2014-ish, I have written and provided many libraries and tools for free to the community, I co-hosted a weekly YouTube show for Corona for several years, I have authored many templates, and I have provided over 400 fully coded solutions, examples and games:

I’m just one of many folks who do similar things for free for folks new and old.

 

 

The thing is, those of us who help have one focus: Helping users to learn to use Corona and solve problems on their own.  OK, maybe that’s two focuses.

 

We (users taking time out from making money) are not here to write entire apps. 

 

We want to help solve fundamental problems, but none of us can afford to do more.  At least I can’t.

 

I would love to have you stay here and be successful, but if you feel this is not the place for you or that we’re all just terrible lying so-and-sos, You might try asking the same question in some other engine/sdk forums to see if we are bad or if it is the same everywhere.

 

If you’re familiar with Lua, you can try Defold and/or LÖVE.  They are both pretty good and they have semi-active communities. 

 

 

Best of luck to you on this.  I hope you stay and continue to ask for help as needed.

 

Cheers,

Ed (aka the Roaming Gamer)

Haha, our posts look slightly out of context now…

Dang it.  The post I responded to got deleted… sigh.  

Oh well, I hope he stays and is successful on this.

I’m going to drop back to a different level of understanding here.

When you put something on the screen, be it a background image, a button to interact with, some piece of text (which includes number to display to users) You are creating a display object. All display objects have various properties that can be changed, properties that you can only look at, and methods or functions that let you do things a little more complicated that simply changing properties.

All display objects are typically stored in a variable so you can reference it easier:

local myText  = display.newText("hello world", 100, 200, native.systemFont, 24)

will create a text string with the contents “hello world”, position it at 100 points left of your content area, 200 points down from the top of your content area, using a font called native.systemFontBold that’s 24 points high.  The references to that display object will be stored in a variable named myText.  There are other things like the color of text that default to preset values. Color for instance defaults to white.

Now, this is just an example. “myText” is probably one of the most useless variable names you can use. It has no meaning. Perhaps making the variable name something more practical like:

local welcomeText  = display.newText("hello world", 100, 200, native.systemFont, 24)

would make more sense. A good programmer will use good variable names because if your app is full of “myText”, that really doesn’t say much.  A table can contain multiple display objects. This is what your “spots” array is. Therefore “spots[1]” is a display object that you can manipulate.

You can change its value by changing the text property. Sticking with the second example, you can change the value by doing:

welcomeText.text = "Hello World! How are you?"

You will see the screen update with the new text. You can move it lower on the screen by changing it’s .y attribute:

welcomeText.y = 250

Now to change the color to red:

welcomeText:setFillColor( 1, 0, 0 )

You don’t have a welcome text, you have a table of spots, so to change the vertical position of the 3rd spot:

spots[3].y = 250

or more practically to change the middle item (13) to the text “Free” since it’s a free space in Bingo:

spots[13].text = "Free"

But if you consider my BINGO code I posted earlier, the free space is in the N column in the third slot:

N\_spots[3].text = "Free"

Hopefully, this will give you a critical piece that you’re missing. 

Rob

Ah, @nick_sherman and @roaminggamer, I now see the missing post that was deleted. Mail notifications are a good thing :slight_smile:

Just to clarify, we have over 500,000 developers. Most people come to the forums, learn how to use the product and don’t hang out here after they learn. But we have an active forum and there are quite a few very helpful developers who do hang out here offering help at no expense to the community (and the Staff at Corona Labs is eternally grateful for this). 

Corona staff actively monitors the forums, but as to avoid dominating all the conversations, we have to pick and choose which topics we respond to. As such, if it’s a product-specific question, I feel we are the best to answer. If it’s a “How do I use the product” question, those are best for the community to answer. If I’m going about this in the wrong way, let me know. Our community developers build and deploy way more games than our staff does and therefore has more experience on what can be done with the product. This thread is a great example. I worked on a BINGO game back in the 1990’s on the server side in C. Not very practical on building a BINGO game in Corona, but @roaming_gamer has. He’s a much better resource to answer that “How do I” question…

We (Corona Labs) and I believe the community developers all want everyone to be successful and use Corona for years. As for lack of information, I’m pretty sure all of this is explained in our Getting Started Guide. http://docs.coronalabs.com/guide/programming/index.html

But all that said, tutorials have to be generic where possible, but there are times where they get very specific and that specificity is very unlikely going to directly translate to copy and paste code. Tutorials are there to teach you concepts that you will adapt to your own use.

Rob

I had received from Rob the code for a bingo game (Thank you so much)  I have styled this around your tutorial on the Tic-Tac-Toe game where you have a reset button.  The reset is has code of

local function resetGame() for i = 1, #spots do spots[i].moveText.text = " " spots[i].moveType = nil end display.remove( winningLine ) winningLine = nil display.remove( winningRec ) winningRec = nil display.remove( winningImage ) display.remove( resetButton ) resetButton = onPress player = "X" allowMoves = true end

This works well.  Is there a way to add code to shuffle the numbers.  I have tried virtually every combination that I could think of. The section of code to shuffle the bingo card is

local B = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } local I = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 } local N = { 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 } local G = { 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58 ,59, 60 } local O = { 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75 } math.randomseed( os.time() ) -- Seed the pseudo-random number generator local function shuffleTable( t ) if ( type(t) ~= "table" ) then print( "WARNING: shuffleTable() function expects a table" ) return false end local j for i = #t, 2, -1 do j = math.random( i ) t[i], t[j] = t[j], t[i] end return t end shuffleTable( B ) shuffleTable( I ) shuffleTable( N ) shuffleTable( G ) shuffleTable( O )

Thanks again for your help. 

Create a table with the valid numbers in it:

local bingoBalls = {} for i = 1, 75 do     bingoBalls[i] = i end shuffleTable( bingoBalls )

Then just take the balls in order out of the shuffled list.

Rob

I put this into my code and made a button at the bottom of the code 

local button3 = widget.newButton( { width = 60, height = 35, defaultFile = "btn green.png", overFile = "btn yellow.png", label = "", onPress = bingoBalls } ) -- Center the button button3.x = display.contentCenterX button3.y = display.contentCenterY -90 -- Change the button's label text button1:setLabel( "" )

Trying to reference it to shuffle the table.  It doesn’t shuffle the numbers.

bingoBalls is not a function, it is a table containing a series of numbers.

You need to point onPress at a function that calls shuffleTable(bingoBalls).

How do I do that?  I thought that was what I was doing.

You have written onPress = bingoBalls. This tells the button to call the function bingoBalls when it is pressed. As bingoBalls is not a function, nothing happens.

You need to write a function that contains the shuffleTable(bingoBalls) call. Then change bingoBalls to the name of the new function. Ensure this function is above the code that creates the button so it is in scope.

I have a function called "shuffleTable (t)

local function shuffleTable( t ) if ( type(t) ~= "table" ) then print( "WARNING: shuffleTable() function expects a table" ) return false end local j for i = #t, 2, -1 do j = math.random( i ) t[i], t[j] = t[j], t[i] end return t end shuffleTable( B ) shuffleTable( I ) shuffleTable( N ) shuffleTable( G ) shuffleTable( O ) local B\_spots = {} local I\_spots = {} local N\_spots = {} local G\_spots = {} local O\_spots = {} for i = 1, 5 do B\_spots[i] = display.newText( B[i], 45, i \* 105, native.systemFontBold, 28 ) B\_spots[i] : setFillColor(1, 1, 1 ) I\_spots[i] = display.newText( I[i], 100, i \* 105, native.systemFontBold, 28 ) B\_spots[i] : setFillColor(1, 1, 1 ) N\_spots[i] = display.newText( N[i], 160, i \* 105, native.systemFontBold, 28 ) B\_spots[i] : setFillColor(1, 1, 1 ) G\_spots[i] = display.newText( G[i], 220, i \* 105, native.systemFontBold, 28 ) B\_spots[i] : setFillColor(1, 1, 1 ) O\_spots[i] = display.newText( O[i], 280, i \* 105, native.systemFontBold, 28 ) B\_spots[i] : setFillColor(1, 1, 1 ) B\_spots[i].y = math.floor( ( i - 1 ) / 1 ) \* 60 + 205 I\_spots[i].y = math.floor( ( i - 1 ) / 1 ) \* 60 + 205 N\_spots[i].y = math.floor( ( i - 1 ) / 1 ) \* 60 + 205 G\_spots[i].y = math.floor( ( i - 1 ) / 1 ) \* 60 + 205 O\_spots[i].y = math.floor( ( i - 1 ) / 1 ) \* 60 + 205 B\_spots[i].moveType = nil I\_spots[i].moveType = nil N\_spots[i].moveType = nil G\_spots[i].moveType = nil O\_spots[i].moveType = nil spots[i]:addEventListener( "touch", handleMove ) end N\_spots[3].text = " " for k = 1, 1 do spots[k] = display.newRect( 0, 0, 55, 55) spots[k]:setFillColor( 0.2,0.2,0.2,0 ) spots[k].x = ( k - 1 ) % 5 \* 60 + 40 spots[k].y = math.floor( ( k - 1 ) / 5 ) \* 60 + 205 spots[k].moveText = display.newText( " ", spots[k].x, spots[k].y, native.systemFontBold, 60) spots[k].moveType = nil spots[k]:addEventListener( "touch", handleMove ) end

I also have the “Reset” of the game that resets everything but the shuffle

local function resetGame() for i = 1, #spots do spots[i].moveText.text = " " spots[i].moveType = nil end display.remove( winningLine ) winningLine = nil display.remove( winningRec ) winningRec = nil display.remove( winningImage ) display.remove( resetButton ) resetButton = onPress player = "X" allowMoves = true end 

Is there a way I could add code to this that would allow me to shuffle the numbers from table t when reset is pressed.  I am truely trying to figure this out but I am stuck. 

No, I mean put the CALL to the shuffleTable function inside another one. When you run a function, that is called ‘calling’ the function.

[lua]

local function shuffleBingoBalls()

  tableShuffle(bingoBalls)

end

[/lua]

Then edit button:

[lua]

local button3 = widget.newButton(

{
width = 60,
height = 35,
defaultFile = “btn green.png”,
overFile = “btn yellow.png”,
label = “”,
onPress = shuffleBingoBalls
}
)

[/lua]

We need to ‘wrap’ the call to tableShuffle because the button listener cannot be passed custom parameters. 

We could not do for example: onPress = tableShuffle(bingoBalls)

So we must call an intermediary function that does this step for us.

The table I am trying to shuffle is labeled “t”.  I put the first part of the code up higher in my code as the first function.  I put the button at the bottom of the code. I get the error,

"main.lua35:attempt to call global’tableShuffle’ (a nil value) stack traceback: 

main.lua:35: in function ‘_onPress’

?:in function ‘?’

?:in function ‘?’

?:in function <?:190>"

If I change the 

tableShuffle(bingoBalls)

to

tableShuffle(t)

I get the same error.

Mark,

I am coming into this late… and know nothing of all the issues or the initial question…  but to the last error message posted…   if you look closely at the error messages, there are clues.

your note list error as  :

attempt to call global’tableShuffle’ (a nil value)

I think you have, in your sample code,  just above nick_sherman’s last post the function called ‘shuffleTable’ …

so tableShuffle is wrong … it should be shuffleTable

I hope this helps, and again I have not read any of this post except your last two posts to this issue.  But I think that is the cause of the error you posted.

Good luck

Bob

it gives the same error, except with shuffleTable instead of tableShuffle

My guess is that the function you are calling is not visible in the scope you are calling it.

i.e. If you did this, you’d get a similar error:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/10/scopeAndVisibility.zip

local function test2() print("\n\nGets an error...") doit() end local function doit() print("YO I'm visible to test1(), but not test2()") end local function test1() print("\n\nWorks fine...") doit() end test1() test2()

Produces this log:

15:28:06.036 Works fine... 15:28:06.036 YO I'm visible to test1(), but not test2() 15:28:06.036 15:28:06.036 15:28:06.036 Gets an error... 15:28:06.036 ERROR: Runtime error 15:28:06.036 X:\Work\00\_CurentProjects\Corona\RG\_FreeStuff\AskEd\2018\10\scopeAndVisibility\main.lua:8: attempt to call global 'doit' (a nil value) 15:28:06.036 stack traceback: 15:28:06.036 X:\Work\00\_CurentProjects\Corona\RG\_FreeStuff\AskEd\2018\10\scopeAndVisibility\main.lua:8: in function 'test2' 15:28:06.036 X:\Work\00\_CurentProjects\Corona\RG\_FreeStuff\AskEd\2018\10\scopeAndVisibility\main.lua:22: in main chunk