unexpected symbol near 'T' what is this?

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
hello outlanders,
I wonder to know what is that error using windows tfs 0.4 tibia 860
when tfs starts to load the globalevents I got this error

[17:54:03.781] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/staminaquest.lua)
[17:54:03.781] data/globalevents/scripts/staminaquest.lua:136: unexpected symbol near '┬'
and this is the code

Lua:
function del(pos, id)
    local thing = getTileItemById(pos, id).uid   <<--this is line 136
    if thing > 0 then
        doRemoveItem(thing)
    end
end

function onThink(interval, lastExecution)
local poss1 = {
{x = 1012, y = 997, z = 7},
{x = 1015, y = 1006, z = 7}
}

if getGlobalStorageValue(str) == 1 then -- remove 3rd walls and create first walls line

setGlobalStorageValue(str, 2)
for i  = 1, #poss3 do  --remove 3rd walllls
del(poss3[i], wall_id)
end
for i  = 1, #poss1 do  --create 1st walls
reset_walls(poss1[i], wall_id)
end
return true
this should remove some walls from some positions, then create others, remove them after x delay and create others...and so on
REP++
 

Danger II

FluppiX.com
Joined
Nov 21, 2012
Messages
1,597
Reaction score
392
Location
Germany
The code you posted seems correct, I doubt this is the right line, could you post the whole script?
 

Danger II

FluppiX.com
Joined
Nov 21, 2012
Messages
1,597
Reaction score
392
Location
Germany
I can't edit my post, but you should check if the function closes properly.

Can't find a "end" for this code:
Lua:
if getGlobalStorageValue(str) == 1 then -- remove 3rd walls and create first walls line
And not sure if the function end's correct. (at least the code you posted, does not close the function)
 

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Reaction score
35
Lua:
local poss1 = {
    {x = 1012, y = 997, z = 7},
    {x = 1015, y = 1006, z = 7}
}

function del(pos, id)
    local thing = getTileItemById(pos, id).uid
    if thing > 0 then
        doRemoveItem(thing)
    end
end

function onThink(interval, lastExecution)
    if getGlobalStorageValue(str) == 1 then
        setGlobalStorageValue(str, 2)
        for i  = 1, #poss3 do  --remove 3rd walllls
            del(poss3[i], wall_id)
        end

        for i  = 1, #poss1 do  --create 1st walls
            reset_walls(poss1[i], wall_id)
        end
    end
    return true
end
 
OP
5

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
I can't edit my post, but you should check if the function closes properly.

Can't find a "end" for this code:
Lua:
if getGlobalStorageValue(str) == 1 then -- remove 3rd walls and create first walls line
And not sure if the function end's correct. (at least the code you posted, does not close the function)
I will share the whole script now
 
OP
5

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
Lua:
local poss1 = {
{x = 1012, y = 997, z = 7},
{x = 1015, y = 998, z = 7},
{x = 1012, y = 1001, z = 7},
{x = 1015, y = 1002, z = 7},
{x = 1012, y = 1005, z = 7},
{x = 1015, y = 1006, z = 7}
}

local poss2 = {
{x = 1012, y = 996, z = 7},
{x = 1015, y = 997, z = 7},
{x = 1012, y = 1000, z = 7},
{x = 1015, y = 1001, z = 7},
{x = 1012, y = 1004, z = 7},
{x = 1015, y = 1005, z = 7}
}

local poss3 = {
{x = 1012, y = 995, z = 7},
{x = 1015, y = 996, z = 7},
{x = 1012, y = 999, z = 7},
{x = 1015, y = 1000, z = 7},
{x = 1012, y = 1003, z = 7},
{x = 1015, y = 1004, z = 7}
}

local wall_id = 1201
local str = 1524 --global storage to check which mw is created now
local delaay = 2500 --time between remove and create
--str -1 not working, 0 going to work, 1== wall 1 line will created, 2== wall line 2 will create now, 3== wall 3 will created
local function del(pos, id)
    local thing = getTileItemById(pos, id).uid
    if thing > 0 then
        doRemoveItem(thing)
    end
end

local function reset_walls(pos, id)
    local thing = getTileItemById(pos, id).uid
    if thing < 1 then
        doCreateItem(id, 1, pos)
    end
end

function onThink(interval, lastExecution)
if getGlobalStorageValue(str) == 1 then -- remove 3rd walls and create first walls line
setGlobalStorageValue(str, 2)
for i  = 1, #poss3 do  --remove 3rd walllls
del(poss3[i], wall_id)
end
for i  = 1, #poss1 do  --create 1st walls
reset_walls(poss1[i], wall_id)
end
return true

elseif getGlobalStorageValue(str) == 2 then -- remove 1st walls and create 2nd walls line
setGlobalStorageValue(str, 3)
for i  = 1, #poss1 do  --remove 1st walllls
del(poss1[i], wall_id)
end
for i  = 1, #poss2 do  --create 2nd walls
reset_walls(poss2[i], wall_id)
end
return true
elseelseif getGlobalStorageValue(str) == 3 then -- remove 1st walls and create 2nd walls line
setGlobalStorageValue(str, 1)
for i  = 1, #poss2 do  --remove 2nd walllls
del(poss2[i], wall_id)
end
for i  = 1, #poss3 do  --create 3rd walls
reset_walls(poss3[i], wall_id)
end
return true
end
return true
end
this is always working,, when storage is 1 it should remove walls' line 1 and create line 2 then set storage 2..with interval 3 seconds,, when storage is 2 it remove wall 2 and create walls on line 3,,, and so on the exe error line is >>> local thing = getTileItemById(pos, id).uid <<--
 

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Reaction score
35
Lua:
local config = {
    poss1 = {
        {x = 1012, y = 997, z = 7},
        {x = 1015, y = 998, z = 7},
        {x = 1012, y = 1001, z = 7},
        {x = 1015, y = 1002, z = 7},
        {x = 1012, y = 1005, z = 7},
        {x = 1015, y = 1006, z = 7}
    },
    poss2 = {
        {x = 1012, y = 996, z = 7},
        {x = 1015, y = 997, z = 7},
        {x = 1012, y = 1000, z = 7},
        {x = 1015, y = 1001, z = 7},
        {x = 1012, y = 1004, z = 7},
        {x = 1015, y = 1005, z = 7}
    },
    poss3 = {
        {x = 1012, y = 995, z = 7},
        {x = 1015, y = 996, z = 7},
        {x = 1012, y = 999, z = 7},
        {x = 1015, y = 1000, z = 7},
        {x = 1012, y = 1003, z = 7},
        {x = 1015, y = 1004, z = 7}
    },
    wall_id = 1201,
    str = 1524, --global storage to check which mw is created now
    delaay = 2500 --time between remove and create
}

local function del(pos, id)
    local thing = getTileItemById(pos, id).uid
    if thing > 0 then
        doRemoveItem(thing)
    end
end
local function reset_walls(pos, id)
    local thing = getTileItemById(pos, id).uid
    if thing < 1 then
        doCreateItem(id, 1, pos)
    end
end
function onThink(interval, lastExecution)
    if getGlobalStorageValue(config.str) == 1 then -- remove 3rd walls and create first walls line
        setGlobalStorageValue(config.str, 2)
        for i  = 1, #config.poss3 do  --remove 3rd walllls
            del(config.poss3[i], config.wall_id)
        end
        for i  = 1, #config.poss1 do  --create 1st walls
            reset_walls(config.poss1[i], config.wall_id)
        end
        return true
    elseif getGlobalStorageValue(config.str) == 2 then -- remove 1st walls and create 2nd walls line
        setGlobalStorageValue(config.str, 3)
        for i  = 1, #config.poss1 do  --remove 1st walllls
            del(config.poss1[i], config.wall_id)
        end
        for i  = 1, #config.poss2 do  --create 2nd walls
            reset_walls(config.poss2[i], config.wall_id)
        end
        return true
    elseif getGlobalStorageValue(config.str) == 3 then -- remove 1st walls and create 2nd walls line
        setGlobalStorageValue(config.str, 1)
        for i  = 1, #config.poss2 do  --remove 2nd walllls
            del(config.poss2[i], config.wall_id)
        end
        for i  = 1, #config.poss3 do  --create 3rd walls
            reset_walls(config.poss3[i], config.wall_id)
        end
        return true
    end
    return true
end
 
OP
5

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
again nothing happens
[23:8:06.345] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/staminaquest.lua)
[23:8:06.345] data/globalevents/scripts/staminaquest.lua:105: unexpected symbol near '┬'

Code:
local config = {
    poss1 = {     <<-- this is line 105
 

Leesne

Member
Joined
Dec 4, 2017
Messages
89
Reaction score
36
I think its something related to above the code you posted.. 105th line.
Check the code above it.
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,556
Reaction score
2,105
save the file with utf-8 encoding
or try utf-16
 
OP
5

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
how I do this with lua file and notepad ++?



its already now with utf 8 and utf 16 not exist with notepad plus plus
 

Leesne

Member
Joined
Dec 4, 2017
Messages
89
Reaction score
36
I just replicated an error similar to this with some older code.
Click encoding menu convert to UTF-8 as Vulcan_ said.


If not delete the current file on both server and local pc and create new one, ensuring its utf8

Also, is unix LF or windows CR LF set down in the bottom right corner.

Some software can't handle the line breaks that the two offer.
 
Last edited:
Top