Forum

> > CS2D > Scripts > Bad argument to tile #1
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bad argument to tile #1

4 replies
To the start Previous 1 Next To the start

moved Bad argument to tile #1

J4x
User Off Offline

Quote
Hi guys i was making a test script, but when i open the console it says me bad argument to tile #1 (number expected got nil)
1
2
3
4
5
6
7
addhook("hit","kill")
function kill(id,source,weapon,hpdmg,apdmg)
local b = tile(x,y,"property")
if b== obstacle then
return 1
end
end

Admin/mod comment

Spam for not putting it in the correct section /TKD

old Re: Bad argument to tile #1

Yasday
User Off Offline

Quote
x = nil (not declared)
y = nil (not declared)
x and y have to be number values.

Edit:
Afterwards, you have to declare obstacle.

old Re: Bad argument to tile #1

J4x
User Off Offline

Quote
but i like to x and y be random numbers, and how do i declare obstacles? and why this works? ->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
TileMaterial = {
     [0] = "Soundless",
     [1] = "Wall",
     [2] = "Obstacle",
     [3] = "Wall (No Shadow)",
     [4] = "Obstacle (No Shadow)",
     [10] = "Dirt",
     [11] = "Snow",
     [12] = "Step",
     [13] = "Tile",
     [14] = "Water",
     [15] = "Metal",
     [16] = "Wood",
     [50] = "Deadly - Normal",
     [51] = "Deadly - Explosion",
     [52] = "Deadly - Toxic",
     [53] = "Deadly - Abyss"
     }
addhook("movetile","breath")
function breath(id,x,y)
local z = tile(x,y,"property")
if z==14 then
timer(1000,"parse","slap "..id)
end
end

old Re: Bad argument to tile #1

DC
Admin On Online

Quote
because x and y are declared in the function:
breath(id,x,y)
(this is possible because the movetile hook provides these coordinates)

variables which are not declared have no value (nil). they do NOT have a random value. you must assign a random value using math.random(min,max) if you want to have a random value.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview