• 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.0] x Item(s) spawn at x,y,z, location every x amount of seconds (or minutes) [Solved!]

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,296
Reaction score
441
Hey, I was wondering if anyone would be able to create such a script template for me. Compatible with TFS 1.0 please :)

Edit: Also, if you could, maybe have a config in which you can give "x" Item that is spawned, an Action or UID.
 
Code:
local t = {
    -- itemid, count, position, actionId
    {2195, 1, {1000, 1000, 7}, 12345},
    {2487, 1, {1001, 1000, 7}, 12346}
}

function onThink(interval)
    for i = 1, #t do
        local v = t[i]
        local position = Position(v[3][1], v[3][2], v[3][3])
        local item = Item(Game.createItem(v[1], v[2], position):getUniqueId())
        item:setActionId(v[4])
        position:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
Last edited:
Just to clarify is it

local t = {
{itemid, item count, {posx, posy, posz}, actionid},

or

local t = {
{itemid, item count, {posx, posy, posz}, milliseconds},
 
I did this:

Code:
local t = {
    -- itemid, count, position, actionId
    {2671, 1, {1487, 954, 7}, 0},
}

function onThink(1000)
    for i = 1, #t do
        local v = t[i]
        local position = Position(v[3][1], v[3][2], v[3][3])
        local item = Item(Game.createItem(v[1], v[2], position):getUniqueId())
        item:setActionId(v[4])
        position:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end

But when I reload globalevents it states that no interval has been set.

7iKbw.png


Also, the globalevents xml states this:

Code:
<globalevent name="Beginning Ham" script="beginning ham.lua" />
 
You need to set the interval in globalevents.xml
Code:
<globalevent name="Beginning Ham" interval="60000" script="beginning ham.lua" />
 
Okay,I found the issue thanks to a wonderful friend named @Cadyan who helped me with the troubleshoot. The fixed version is below! :)

Code:
<globalevent name="Beginning Ham" interval="1000" script="beginning ham.lua" />

Code:
local t = {
    -- itemid, count, position, actionId
    {2671, 1, {1487, 954, 7}, 0},
}

function onThink(1000)
    for i = 1, #t do
        local v = t[i]
        local position = Position(v[3][1], v[3][2], v[3][3])
        local item = Item(Game.createItem(v[1], v[2], position):getUniqueId())
        item:setActionId(v[4])
        position:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end

Explanation:
You set the interval in the xml, and 1000 = 1 second (1000 milliseconds). Once you do that, you configure the item id, its position, and its actionid in the script itself, and you can have multiple items per 1 script (thanks to @Ninja!).

Edit: Dang Ninja, you are quick! I got it fixed before you posted, but I think this post will be useful for anyone wanting the finalized version along with an explanation :)
 
Back
Top Bottom