Hi!
Error i get
____________
[Warning - Event::checkScript] Can not load script: scripts/trainertp.lua
data/movements/scripts/trainertp.lua:4: '}' expected (to close '{' at line 3) near 'of'
[Warning - Event::checkScript] Can not load script: scripts/trainertp2.lua
data/movements/scripts/trainertp2.lua:4: 'do' expected near 'from'
i got in movements.xml
and im working with this lua first for enter the teleport
and when exit the trainers
how do i get this code to work ? :/
thanks!
Error i get
____________
[Warning - Event::checkScript] Can not load script: scripts/trainertp.lua
data/movements/scripts/trainertp.lua:4: '}' expected (to close '{' at line 3) near 'of'
[Warning - Event::checkScript] Can not load script: scripts/trainertp2.lua
data/movements/scripts/trainertp2.lua:4: 'do' expected near 'from'
i got in movements.xml
Code:
<movevent event="StepIn" actionid="14876" script="trainerin.lua"/>
<movevent event="StepIn" actionid="14877" script="trainerout.lua"/>
and im working with this lua first for enter the teleport
Code:
local storage = 5845
local config = {
first_room_pos = { x = 1403 , y = 1252 , z = 7 }, - position of the first pos ( row 1 column 1 )
distX = 12, - distance in X between each room ( on the same row )
distY = 12, - Y distance between each room ( from the same column )
rX = 4, - number of columns
rY = 5 - number of lines
}
local function isBusyable ( position ) local player = Tile ( position ): getTopCreature () if player then if player : isPlayer () then return false end end
local tile = Tile ( position ) if not tile then return false end
local ground = tile : getGround () if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then return false end
local items = tile : getItems () for i = 1 , tile : getItemCount () from local item = items [ i ] local itemType = item : getType () if itemType : getType () ~ = ITEM_TYPE_MAGICFIELD and not itemType : isMovable () and item : hasProperty (
CONST_PROP_BLOCKSOLID ) then return false end end
return true end
local function addTrainers ( position , arrayPos ) if not isBusyable ( position ) then for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if not trainer then local monster = Game . createMonster ( "Trainer" , arrayPos [ places
])
monster : getPosition (): sendMagicEffect ( CONST_ME_MAGIC_BLUE ) end end end end
local function calculatingRoom ( uid , position , column , row ) local player = Player ( uid ) if column > = config . rX then
column = 0
line = line < ( config . rY - 1 ) and line + 1 or false end
if line then local room_pos = { x = position . x + ( column * config . DISTX ), y = position . y + ( line * config . distY ), z = position . z } if isBusyable ( room_pos ) then
player : teleportTo ( room_pos )
player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
addTrainers ( room_pos , {{ x = room_pos . x - 1 , y = room_pos . y + 1 , z = room_pos . z }, { x = room_pos . x + 1 , y = room_pos . y + 1 , z = room_pos . z }}) else
calculatingRoom ( uid , position , column + 1 , row ) end else
player : sendCancelMessage ( "Couldn't find any position for you right now." ) end end
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
if creature : getStorageValue ( storage ) - os . time () > 0 then
creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
creature : teleportTo ( fromPosition , true ) return true end
calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 )
return true end
and when exit the trainers
Code:
local storage = 5845
local function removeTrainers ( position ) local arrayPos = {{ x = position . x - 1 , y = position . y + 1 , z = position . z }, { x = position . x + 1 , y = position . y + 1 , z = position .
z }} for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if trainer then if trainer : isMonster () then
trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
trainer : remove () end end end end
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
removeTrainers ( fromPosition )
creature : teleportTo ( creature : getTown (): getTemplePosition ())
creature : setStorageValue ( storage , os . time () + 5 )
return true end
how do i get this code to work ? :/
thanks!