Stuck in learning

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Harry_Nightmare
Prole
Posts: 2
Joined: Mon Sep 19, 2022 3:58 am

Stuck in learning

Post 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)
Attachments
main.lua
(7.34 KiB) Downloaded 53 times
Button.lua
(2.15 KiB) Downloaded 46 times
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Stuck in learning

Post 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.
Harry_Nightmare
Prole
Posts: 2
Joined: Mon Sep 19, 2022 3:58 am

Re: Stuck in learning

Post by Harry_Nightmare »

Im forgot set it to playerflag. And now its working. Thanks a lot!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest