• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.2 is Position(x, y, z) default tfs feature?

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
Yo got an question what i noticed people use Position(x, y, z) and they dont add any script to a code so probably because its a stock feature in TFS right? So i tried using it on my local config but that shit didnt worked :D maybe information i have is false i guess because i mean

Lua:
monsterSystem = {
    [1] = {name = "Monster 1", expReward = 10000, Position(45, 522, 6), itemRewards = {
        { itemId = 6857, itemCount = 45, chance = 100 },
        { itemId = 5683, itemCount = 1, chance = 50 },
        { itemId = 5684, itemCount = 1, chance = 50 },
        { itemId = 5685, itemCount = 1, chance = 50 },
        { itemId = 5686, itemCount = 1, chance = 50 }
    }},
This entire monsterSystem is in global.lua which works like when you kill a monster you get those rewards (its combined with creaturescript) so i though if i kill monster this Position(45, 522, 6) should teleport me out somewhere, but didnt worked. Ideas?
 
Solution
E
i mean do you see he added Position(1661, 106, 7)}, and there is nothing related to Position in a code
it is used right there:
local MONS = Game.createMonster(BOSS_PICKED[1], BOSS_PICKED[2])

CRniFjf.png


I don't really have words to explain it in a proper manner but that is it, hope someone can explain it better to you
Yo got an question what i noticed people use Position(x, y, z) and they dont add any script to a code so probably because its a stock feature in TFS right? So i tried using it on my local config but that shit didnt worked :D maybe information i have is false i guess because i mean

Lua:
monsterSystem = {
    [1] = {name = "Monster 1", expReward = 10000, Position(45, 522, 6), itemRewards = {
        { itemId = 6857, itemCount = 45, chance = 100 },
        { itemId = 5683, itemCount = 1, chance = 50 },
        { itemId = 5684, itemCount = 1, chance = 50 },
        { itemId = 5685, itemCount = 1, chance = 50 },
        { itemId = 5686, itemCount = 1, chance = 50 }
    }},
This entire monsterSystem is in global.lua which works like when you kill a monster you get those rewards (its combined with creaturescript) so i though if i kill monster this Position(45, 522, 6) should teleport me out somewhere, but didnt worked. Ideas?
You didn't attach any error message, so crystal ball time.

Most likely you are trying to assign a value to a hashmap without a key, but I'm not 100% positive it would give an error in Lua.
expReward = 10000, Position(45, 522, 6)

Also, the thing you attached is just a config, not an actual logic - did you implement anything to handle this Position?
and yes, Position() is something that comes with your engine.


If you are wondering which built-in Lua functions can you call, you can just visit your src/luascript.cpp, you can see actual C++ implementations there.
 
Last edited:
You didn't attach any error message, so crystal ball time.

Most likely you are trying to assign a value to a hashmap without a key, but I'm not 100% positive it would give an error in Lua.


Also, the thing you attached is just a config, not an actual logic - did you implement anything to handle this Position?
and yes, Position metatable is something that comes with your engine.
If you are wondering which built-in Lua functions can you call, you can just visit your src/luascript.cpp, you can see actual C++ implementations there.
I mean there is no errors i just saw people putting Position(x, y, z) to a local and nothing handles that position and it works.
now I'm really curious 😁 where did you saw this?

Position(100, 100, 7) is the "same" as the old {x = 100, y = 100, z = 7}
TFS 1.2 How can i edit this code so it would spawn only one Boss (https://otland.net/threads/tfs-1-2-how-can-i-edit-this-code-so-it-would-spawn-only-one-boss.273908/page-2)
i mean do you see he added Position(1661, 106, 7)}, and there is nothing related to Position in a code
 
i mean do you see he added Position(1661, 106, 7)}, and there is nothing related to Position in a code
it is used right there:
local MONS = Game.createMonster(BOSS_PICKED[1], BOSS_PICKED[2])

CRniFjf.png


I don't really have words to explain it in a proper manner but that is it, hope someone can explain it better to you
 
Solution
it is used right there:
local MONS = Game.createMonster(BOSS_PICKED[1], BOSS_PICKED[2])

CRniFjf.png


I don't really have words to explain it in a proper manner but that is it, hope someone can explain it better to you
Hmmmm, maybe this should work then?
Lua:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local percent = creature:getMaxHealth() * 0.50
    for k, v in pairs(monsterSystem) do
            if v.name:lower() == creature:getName():lower() then
            for pid, info in pairs(creature:getDamageMap()) do
                local player = Player(pid)
                if player and info.total >= percent then
                    player:addExperience(v.expReward, true)
                    player:addMoney(v.goldReward)
                    player:addItem(v.itemReward, v.itemCount) -
                    player:addEventPoints(v.pointsReward)
                    player:doTeleportThing(v.destination) -- this part
                    for _, reward in pairs(v.itemRewards) do
                    if math.random(1,100) <= reward.chance then
                    player:addItem(reward.itemId, reward.itemCount)
                    end
                end
                end
            end
        end
    end
    return true
end
and in global
Lua:
destination = { x = 324, y = 1113, z = 8 },
or no?
 
Back
Top