Page 1 of 1

Stuck in learning

Posted: Mon Sep 19, 2022 4:04 am
by Harry_Nightmare
Good day. Im trying to understand the Love2d and Lua. And when i wrote simple game tic tac toe, it is stop working, when i try to add menu and rework program. It is incomplite, i know, but my problem is function drawCell is just stop working and i don't understand why. Can someone explain, what exactly can call this error?

main.lua:236: attempt to perform arithmetic on local 'cell_state' (a table value)

Re: Stuck in learning

Posted: Mon Sep 19, 2022 10:23 am
by pgimeno
In lines 114-115 you're doing:

Code: Select all

    if field[number] == 0 then
      field[number] = player
      ...
`player` is a table, not a number, so when you pass field[i] to drawCell as the cell_state, it fails when you use cell_stateCase[cell_state+1] because cell_state is a table, not a number, so you can't add 1 to it.

Re: Stuck in learning

Posted: Mon Sep 19, 2022 12:20 pm
by Harry_Nightmare
Im forgot set it to playerflag. And now its working. Thanks a lot!