TFS 0.X Teleport to trainer

newby

Banned User
Joined
Jun 11, 2016
Messages
164
Best answers
0
Reaction score
38
Is this possible to do, when player enter in trainers teleport, insted of teleport him to the center of room


And he have to search for a empty trainer, if there is

Player be teleported to the trainer


I mean check the tile positions and if dont have no one teleport him, and if all tiles are in use just send a message and dont teleport?

My trainer tiles positions:
Code:
128,929,8
132,292,8
136,292,8
140,292,8
144,292,8
148,292,8
152,292,8
156,292,8
160,292,8
164,292,8
168,292,8
172,292,8
176,292,8
180,292,8
184,292,8
188,292,8
192,292,8
196,292,8
200,292,8
204,292,8
208,292,8
212,292,8
216,292,8
220,292,8


128,938,8
132,938,8
136,938,8
140,938,8
144,938,8
148,938,8
152,938,8
156,938,8
160,938,8
164,938,8
168,938,8
172,938,8
176,938,8
180,938,8
184,938,8
188,938,8
192,938,8
196,938,8
200,938,8
204,938,8
208,938,8
212,938,8
216,938,8
220,938,8
 

Perun

nems.online
Premium User
Joined
May 1, 2009
Messages
294
Best answers
5
Reaction score
116
Yea it is PM me, i can send you one of my old scripts for that. It's generic so you don't have to write exacly tp pos. Just left top corner and right bot, script scannik free tiles and teleport player to first empty.
 

Discovery

Developing myself
Joined
Apr 16, 2010
Messages
426
Best answers
7
Reaction score
110
Location
Neverland
I've developed that sometime using a default position between training rooms.

Like how many training rooms exist in the same line (x), and the count of columns of tranining rooms (y)

And the script will check if exist someone on that training rooms, if not: teleport to.

Logic is:
The difference between a room +7 (in x), if reach the maximum per line add +6 (in y) -> change the column.
 

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,177
Best answers
14
Reaction score
552
Location
Germany
It contains pretty much everything which you need.
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,319
Best answers
33
Reaction score
830
Location
Arica - Chile
It contains pretty much everything which you need.
thats sick, I remember when I saw that post long time ago, it gave me a ton of ideas.
 
OP
newby

newby

Banned User
Joined
Jun 11, 2016
Messages
164
Best answers
0
Reaction score
38
It contains pretty much everything which you need.
@Evil Hero what is this functions/global.lua ???
I've create a file named global.lua in data/libs
And pasted that, but don't work, i think i doing wrong
 

Salvus

Member
Joined
Feb 7, 2019
Messages
93
Best answers
1
Reaction score
61
I want something like this in TFS 1.3 :((
 

Perun

nems.online
Premium User
Joined
May 1, 2009
Messages
294
Best answers
5
Reaction score
116
OP
newby

newby

Banned User
Joined
Jun 11, 2016
Messages
164
Best answers
0
Reaction score
38
To who dont have global.lua on data like me: Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/data)
Make one new global.lua on data/lib
with that script:
Code:
roomIndex = {}

config =
{
room =
{
teleport = 1387,
ground = 406,
nortWestCorner = 1113,
southEastCorner = 1115,
wallFaceNorth = 1116,
wallFaceEast = 1114,
fire = 1484,
trainer = "Training Monk"
},
temple = {x = 3893, y = 3710, z = 6}, -- the position the player will get teleported to if he leaves the training room
startPos = {x = 100, y = 100, z = 6}, -- the top north west position from where we start to create the rooms from.
offset = 5, -- this is the space between each masterPos of the room (can't be lower then 5!)
gridX = 10, -- how much training rooms we create on one x axis
gridY = 10, -- how much training rooms we create on one y axis
gridZ = 3 -- how much layers we use therefor
-- this basicly means we can create in the grid example: 10*10*3 = 300 trainings room in this case.
}

function createTrainingRoom(pos)
local realPos = {x = pos.x - 2, y = pos.y - 2, z = pos.z}
for a = 0,4 do -- here we create the ground
for b = 0,4 do
doCreateItem(config.room.ground, 1, {x = realPos.x + a, y = realPos.y + b, z = realPos.z})
end
end
doCreateItem(config.room.nortWestCorner, 1, realPos) -- we create the north west corner wall
doCreateItem(config.room.southEastCorner, 1, {x = realPos.x + 4, y = realPos.y + 4, z = realPos.z}) -- we create the south east corner wall
for a = 1,4 do -- we create the left wall side which faces north
doCreateItem(config.room.wallFaceNorth, 1, {x = realPos.x, y = realPos.y + a, z = realPos.z})
end
for a = 1,3 do -- we create the right wall side which faces north
doCreateItem(config.room.wallFaceNorth, 1, {x = realPos.x + 4, y = realPos.y + a, z = realPos.z})
end
for a = 1,4 do -- we create the north wall side which faces east
doCreateItem(config.room.wallFaceEast, 1, {x = realPos.x + a, y = realPos.y, z = realPos.z})
end
for a = 1,3 do -- we create the south wall side which faces east
doCreateItem(config.room.wallFaceEast, 1, {x = realPos.x + a, y = realPos.y + 4, z = realPos.z})
end
doCreateItem(config.room.fire, 1, {x = realPos.x + 1, y = realPos.y + 2, z = realPos.z}) -- here we create the fire lights
doCreateItem(config.room.fire, 1, {x = realPos.x + 1, y = realPos.y + 3, z = realPos.z}) -- here we create the fire lights
doCreateItem(config.room.fire, 1, {x = realPos.x + 3, y = realPos.y + 2, z = realPos.z}) -- here we create the fire lights
doCreateItem(config.room.fire, 1, {x = realPos.x + 3, y = realPos.y + 3, z = realPos.z}) -- here we create the fire lights
doSummonCreature(config.room.trainer, {x = realPos.x + 3, y = realPos.y + 1, z = realPos.z}) -- here we create the training monsters
doSummonCreature(config.room.trainer, {x = realPos.x + 1, y = realPos.y + 1, z = realPos.z}) -- here we create the training monsters
local teleport = doCreateItem(config.room.teleport, 1, {x = realPos.x + 2, y = realPos.y + 1, z = realPos.z})
doItemSetAttribute(teleport, "aid", 8771) -- here we create the teleport to leave the room
end

function deleteTrainingRoom(pos)
local playerpos = pos
for x = playerpos.x-2, playerpos.x+2 do
for y = playerpos.y-1, playerpos.y+3 do
for z = playerpos.z, playerpos.z do
local pos = {x=x, y=y, z=z, stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveCreature(thing.uid)
end
local pos = {x=x, y=y, z=z, stackpos = 1}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveItem(thing.uid)
end
local pos = {x=x, y=y, z=z}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveItem(thing.uid)
end
end
end
end
    return true
end

function getNextRoom()
if roomIndex[1] ~= nil then
for a = 1, #roomIndex do
if roomIndex[a] == false then
return a
elseif #roomIndex == a then
roomIndex[#roomIndex + 1] = false
return #roomIndex
end
end
else
return 1
end
end

function getRoomPosFromIndex(id)
local indicator = {x = 0, y = 0, z = 0}
if id > config.gridX * config.gridY then
repeat
id = id - config.gridX * config.gridY
indicator.z = indicator.z + 1
until id <= config.gridX * config.gridY
end
if id > config.gridX then
repeat
id = id - config.gridY
indicator.y = indicator.y + 1
until id <= config.gridY
end
indicator.x = id
local offset = {x = indicator.x * config.offset, y = indicator.y * config.offset, z = indicator.z}
return {x = config.startPos.x + offset.x, y = config.startPos.y + offset.y, z = config.startPos.z + offset.z}
end

function getRoomIndexFromPos(pos)
local x = (pos.x - config.startPos.x) / config.offset
local y = (pos.y - config.startPos.y) / config.offset * config.gridY
local z = (pos.z - config.startPos.z) * (config.gridX * config.gridY)
return (x + y + z)
end

function setRoomInUse(id)
roomIndex[id] = true
end
function setRoomUnused(id)
roomIndex[id] = false
end
 
Top