Forum

> > CS2D > Scripts > Unexpected Lua Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Unexpected Lua Error

13 replies
To the start Previous 1 Next To the start

old Unexpected Lua Error

Obviously Exactly Myself
User Off Offline

Quote
1
LUA ERROR: maps/TEST.lua:1639: attempt to compare number with boolean
I got this error in the "always" hook. Yesterday and any days, I didn't get that error, but now when I didn't touch a thing in my script today, the error appeared. The script works, but that error message is spamming in the console every frame.
What does this error mean and how to fix it?

old Re: Unexpected Lua Error

EngiN33R
Moderator Off Offline

Quote
It means, well, that you're attempting to compare a number value with a boolean (true/false) value. Give us the line or preferably the whole hook function.

old Re: Unexpected Lua Error

Obviously Exactly Myself
User Off Offline

Quote
Spoiler >

old Re: Unexpected Lua Error

Flacko
User Off Offline

Quote
You fucked up in your image handling stuff.

You use shitloads of elseif blocks to make almost identical stuff over and over again = fail

You try to free an image using the id of a player = fail x 2

Then, you assign id (which was the player id) to an image id probably because of code copypasting = fail combo x 3

Later on, you try to call the player() function with the image id you assigned = fail combo x 4

the player() function returns false when you're trying to get an attribute of a player that doesn't exist.

old Re: Unexpected Lua Error

DannyDeth
User Off Offline

Quote
Well, for a start, read carefully what he wrote. You can see somethings:
Using player id instead of image id. This is a bad idea, if you want to do this rather use an array like so:
1
player_images[player_id] = image(..... whatever goes here .....)
then, when you want to handle those images:
1
imagepos(....,....,..,.., player_images[player_id])
That was you won't cause any errors in that aspect.

I can't teach you how to write code, you need to learn yourself.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview