Forum

> > CS2D > Scripts > attempt to call a nil value
Forums overviewCS2D overview Scripts overviewLog in to reply

English attempt to call a nil value

10 replies
To the start Previous 1 Next To the start

old attempt to call a nil value

XeniTh
User Off Offline

Quote
Hello, i have a problem with my script... I just learned some lua a bit and i want to make a script where only I can create soldiers with my F4 button, and i wanted that script for years... But, i dont know why i get the "LUA ERROR: attempt to call a nil value" error... heres my script:
Spoiler >

btw. if you make me the script wrong... never mind... i just want the script to work. thanks.
edited 3×, last 13.06.11 09:29:30 pm

old Re: attempt to call a nil value

DC
Admin Off Offline

Quote
does Lua have a function/keyword called "Array"? If not: problem found.

also the code indention is f*cked up. thise code is - sorry - an unreadable pile of crap.

old Re: attempt to call a nil value

XeniTh
User Off Offline

Quote
user Flacko has written
addhook("serveraction","client123")
function serveraction(id,action)
The names don't match


error: spawnobject - wrong tile properites!

-.-'

if only lua scripting was easy, i would make it for 5 minutes

old Re: attempt to call a nil value

Yates
Reviewer Off Offline

Quote
user XeniTh has written
user Flacko has written
addhook("serveraction","client123")
function serveraction(id,action)
The names don't match


error: spawnobject - wrong tile properites!

-.-'

if only lua scripting was easy, i would make it for 5 minutes

Then there is a building where you are trying to spawn it.

old Re: attempt to call a nil value

XeniTh
User Off Offline

Quote
user Yates has written
user XeniTh has written
user Flacko has written
addhook("serveraction","client123")
function serveraction(id,action)
The names don't match


error: spawnobject - wrong tile properites!

-.-'

if only lua scripting was easy, i would make it for 5 minutes

Then there is a building where you are trying to spawn it.


parse("spawnnpc 5 "..hhx[id].." "..hhy[id].."")

old Re: attempt to call a nil value

DC
Admin Off Offline

Quote
just a random general correction:
1
..""
does NOTHING (it adds an empty string [hence nothing] to your string). so just remove it to make it look better and be faster.

this is a common mistake done by people who don't understand what they are actually doing.

don't mix this up with
1
.." "
this actually ads a space to the string. this doesn't make sense at the end either, but can be important when used in the middle of the string to separate parameters.

old Re: attempt to call a nil value

XeniTh
User Off Offline

Quote
user DC has written
just a random general correction:
1
..""
does NOTHING (it adds an empty string [hence nothing] to your string). so just remove it to make it look better and be faster.

this is a common mistake done by people who don't understand what they are actually doing.

don't mix this up with
1
.." "
this actually ads a space to the string. this doesn't make sense at the end either, but can be important when used in the middle of the string to separate parameters.


you mean this: parse("spawnnpc 5 "..hhx[id]..""..hhy[id].."") or what?

old Re: attempt to call a nil value

DC
Admin Off Offline

Quote
no, what I said is:
× .."" is ALWAYS pointless. remove it.
√ .." " is not pointless (in most cases). keep it.

so I was talking about the .."" at the end of that line.
> this is NOT the reason for the error though!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview