English Why error safezone

5 replies
Goto Page
To the start Previous 1 Next To the start
30.08.13 02:08:47 am
Up
pbeloto
User
Offline Off
Hi us

plz why error line

Code:
1
if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then


error conssole

Code:
1
2
LUA ERROR: sys/lua/safezone.lua:24: attempt to compare number with bool
ean



script
Code:
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
26
27
28
29
addhook("hit", "_hit")
addhook("movetile", "_movetile")

function _hit(id,pl)
     if _safezone(id) then
          return 1;
     elseif _safezone(pl) then
          return 1;
     end
end

function _movetile(id,x,y)
     if _safezone(id) then
          parse('hudtxt2 '..id..' 11 "'..t_color["azulm"]..'SAFE ZONE" 320 200 1');
     elseif not _safezone(id) then
          parse('hudtxt2 '..id..' 11 ""');
     end
end

function _safezone(id)
     local tilex = player(id,"tilex");
     local tiley = player(id,"tiley");
     for _, i in pairs(safezones) do
          if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then
               return true;
          end
     end
     return false;
end
30.08.13 02:18:10 am
Up
KimKat
GAME BANNED
Offline Off
I'm not all too sure what might be causing this error, someone else might have the answer though. The Lua script seems to compare a number within your multi dimension array (which is not visible in the code snippet) with a boolean value.

A boolean value is basically (true/false or 1/0). That's all I can tell from this Lua script currently.
30.08.13 02:56:26 am
Up
sheeL
User
Offline Off
Post the complete code.
30.08.13 06:09:03 am
Up
MikuAuahDark
User
Offline Off
make sure that variable i with index 1 or 2(multi) doesn't give a boolean value. you can try to debug your script by put this script
Code:
1
print(tostring(i[1][2]))
below
Code:
1
for _, i in pairs(safezones) do


Make sure to use all possible index

Also only if you want, you can post the safezones table
Hello? Are you there, Tae Hanazono?
30.08.13 05:14:32 pm
Up
M_
User
Offline Off
Code:
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
safe = {}

for _,e in pairs(entitylist()) do
     if entity(e.x,e.y,"typename") == "Env_Hurt" and entity(e.x,e.y,"int0") == -100 and entity(e.x,e.y,"int1") == 2 then
          local x=e.x
          local y=e.y
          local x2=(e.x-1)+entity(e.x,e.y,"int2")
          local y2=(e.y-1)+entity(e.x,e.y,"int3")
          
          table.insert(safe,{x,x2,y,y2})
     end
end

function init_array(length,mode)
     local array = {}
     for i = 1,length do 
          array[i] = mode     
     end
     return array
end

player_safe = init_array(32,false)

addhook("movetile","movetile")
addhook("hit","hit")

function hit(id,)
     if player_safe[id] then
          return 1
     end
     return 0
end

function movetile(id,x,y)
     for i in ipairs(safe) do
          if x >= safe[i][1] and x <= safe[i][2] and y >= safe[i][3] and y <= safe[i][4] then
               player_safe[id] = true
               break
          else
               player_safe[id] = false
          end
     end     
     update_hud(id)
end

function update_hud(id)
     if player_safe[id] then
          parse("hudtxt2 "..id.." 1 \"SAFE ZONE\" 318 200 1")
     else
          parse("hudtxt2 "..id.." 1 \"\" 300 210 0")
     end
end



Put an "Env_Hurt" entity with -100 and both.
See ya.
30.08.13 07:16:41 pm
Up
pbeloto
User
Offline Off
thanks you @user M_:
To the start Previous 1 Next To the start