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)
Stuck in learning
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Mon Sep 19, 2022 3:58 am
Stuck in learning
- Attachments
-
- main.lua
- (7.34 KiB) Downloaded 53 times
-
- Button.lua
- (2.15 KiB) Downloaded 46 times
Re: Stuck in learning
In lines 114-115 you're doing:
`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.
Code: Select all
if field[number] == 0 then
field[number] = player
...
-
- Prole
- Posts: 2
- Joined: Mon Sep 19, 2022 3:58 am
Re: Stuck in learning
Im forgot set it to playerflag. And now its working. Thanks a lot!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest