• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

tfs 1.2 Tables

  • Thread starter Thread starter tejdi
  • Start date Start date
T

tejdi

Guest
Hello! I have got a question and it's connected with tables in LUA.

Let's say that I would like to send a specific effect to 5 coordination on the map.
I've created table that looks like this:

LUA:
local energy = {
a = {x=788, y=976, z=11},
b = {x=796, y=979, z=11},
c = {x=786, y=986, z=11},
d = {x=791, y=981, z=11},
e = {x=790, y=978, z=11}
}

And I would like to send the effects to every sqm from table by one code line (if it is possible)

LUA:
doSendMagicEffect(config.energy[ALL PARAMETERS], CONST_ME_ENERGYHIT)

Something like this would be amazing, but I do not know how to call all the parametrs from the table.

I tried to find tables tutorial on the forum but didn't find anything for tfs 1.2.
 
Solution
Ah I was confused with distance effects, not magic effects.
Here's code with 1.2 style, rather than 0.4.
LUA:
function sendMagicEffectList(list, effect) -- function definition, put this somewhere in your lib files
    for i = 1, #list do
        local pos = list[i]
        pos:sendMagicEffect(effect)
    end
end

local energy = {
    Position(788, 976, 11),
    Position(796, 979, 11),
    Position(786, 986, 11),
    Position(791, 981, 11),
    Position(790, 978, 11)
}

sendMagicEffectList(energy, CONST_ME_ENERGYHIT) -- usage
Are you looking to send a->b->c->d->e? Or are you trying to send from a center position towards a, b, c, d, e?
 
I mean I don't want to receive a shot effect from position X to position Y - doSendMagicEffect( ? , CONST_ME_ENERGYHIT) is fine.

All can happen in one time as with this code:

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

doSendMagicEffect({x=788, y=971, z=11}, CONST_ME_ENERGYHIT)
doSendMagicEffect({x=788, y=972, z=11}, CONST_ME_ENERGYHIT)
doSendMagicEffect({x=788, y=973, z=11}, CONST_ME_ENERGYHIT)
doSendMagicEffect({x=788, y=974, z=11}, CONST_ME_ENERGYHIT)
doSendMagicEffect({x=788, y=975, z=11}, CONST_ME_ENERGYHIT)

end

But as you can see it's not the best looking way :P.

Anyway would be amazing to learn how to send a->b->c->d->e and send from center towards a, b, c, d, e.
More knowledge is just better even if I will not use it right now.
 
Ah I was confused with distance effects, not magic effects.
Here's code with 1.2 style, rather than 0.4.
LUA:
function sendMagicEffectList(list, effect) -- function definition, put this somewhere in your lib files
    for i = 1, #list do
        local pos = list[i]
        pos:sendMagicEffect(effect)
    end
end

local energy = {
    Position(788, 976, 11),
    Position(796, 979, 11),
    Position(786, 986, 11),
    Position(791, 981, 11),
    Position(790, 978, 11)
}

sendMagicEffectList(energy, CONST_ME_ENERGYHIT) -- usage
 
Solution
Back
Top