• 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!

Lua Creating pool of oil with onUse event

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I would like to request a script for TFS 1.4 nekiro 8.6. It simply should drop an specific liquid when the selected item is used on a tile.

script_oil.png

The registered action itemid should be "vial of oil" (id: 13068). The thing that complains me is to create the pool type, specifially 2016, 11, don't know how to do it and drop it in the specific tile I used the "vial of oil". After using the vial, the pool must be on the floor and the "vial of oil" (id:13068) should decay to "empty vial" (id: 13067).

I know this is not the most effective solution for this fluid trouble but as a patch works for me, just wondering how to send the pooltype to the floor.

PS: If sending 2016, 11 as pool type to the floor is not possible, something like Game.createItem(13069, item.type, toPosition) where id:13069 is "pool of oil" works well for me too.

Thanks in advance,
Regards!
 
Solution
Hi! I would like to request a script for TFS 1.4 nekiro 8.6. It simply should drop an specific liquid when the selected item is used on a tile.

View attachment 63565

The registered action itemid should be "vial of oil" (id: 13068). The thing that complains me is to create the pool type, specifially 2016, 11, don't know how to do it and drop it in the specific tile I used the "vial of oil". After using the vial, the pool must be on the floor and the "vial of oil" (id:13068) should decay to "empty vial" (id: 13067).

I know this is not the most effective solution for this fluid trouble but as a patch works for me, just wondering how to send the pooltype to the floor.

PS: If sending 2016, 11 as pool type to the floor is not possible...
Hi! I would like to request a script for TFS 1.4 nekiro 8.6. It simply should drop an specific liquid when the selected item is used on a tile.

View attachment 63565

The registered action itemid should be "vial of oil" (id: 13068). The thing that complains me is to create the pool type, specifially 2016, 11, don't know how to do it and drop it in the specific tile I used the "vial of oil". After using the vial, the pool must be on the floor and the "vial of oil" (id:13068) should decay to "empty vial" (id: 13067).

I know this is not the most effective solution for this fluid trouble but as a patch works for me, just wondering how to send the pooltype to the floor.

PS: If sending 2016, 11 as pool type to the floor is not possible, something like Game.createItem(13069, item.type, toPosition) where id:13069 is "pool of oil" works well for me too.

Thanks in advance,
Regards!

FLUID_OIL = FLUID_BROWN + 8

So you should be able to use FLUID_OIL or the numerical value FLUID_BROWN (3) + 8 -> 11

As far as putting it on the floor, just use the position value, and remember to decay the pool.

Lua:
// Game.createItem(itemId[, count[, position]])
Game.createItem(2016, FLUID_OIL, toPosition):decay()
Game.createItem(2016, 11, toPosition):decay()

and to 'decay' the vial, use transform
Lua:
item:transform(itemId[, count/subType = -1])
item:transform(13067) -- I think?
 
Solution
@Xikini Working perfectly!!!! Thanks again <3

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
Game.createItem(2016, 11, toPosition):decay()
item:transform(13069)
end

There's another doubt where you could help me a lot, if I have for example, my "empty vial" with id: 13069, and I use it in a pool of oil, how a script would know that the pool of oil (id:2016) has the FLUID_OIL /"11" parameter if it points to ID:2016 onLook? and how do I remove the pool when the vial absorbs it?

empty_vial.png

This is intended for "vial of blood". If it is possible that the empty vial can convert into "vial of blood" when absorbing floor blood or a corpse with <attribute key="fluidSource" value="blood" /> would be great

Edit: I'm trying to create the pits of inferno gravestone too, have a mess with it but guess this is a good hint of how to do it??
Lua:
local function graveStoneTeleport(cid, fromPosition, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    player:teleportTo(toPosition)
    player:say('Muahahahaha..', TALKTYPE_MONSTER_SAY, false, player)
    fromPosition:sendMagicEffect(CONST_ME_DRAWBLOOD)
    toPosition:sendMagicEffect(CONST_ME_MORTAREA)
end

If id:13070 = "vial of blood", I must use item.id == 13070 or item.id == 2610 and item.type == FLUID_BLOOD?
Lua:
                if item.id == 13070 and target.actionid == 2023 then
                toPosition.y = toPosition.y + 1
                local creatures, destination = Tile(toPosition):getCreatures(), Position(1296, 808, 10)
                if #creatures == 0 then
                    graveStoneTeleport(player.uid, fromPosition, destination)
                else
                    local creature
                    for i = 1, #creatures do
                        creature = creatures[i]
                        if creature and creature:isPlayer() then
                            graveStoneTeleport(creature.uid, toPosition, destination)
                        end
                    end
                end


Tried to guide myself with this too, without success

Thanks in advance!
Regards
 
Last edited:
There's another doubt where you could help me a lot, if I have for example, my "empty vial" with id: 13069, and I use it in a pool of oil, how a script would know that the pool of oil (id:2016) has the FLUID_OIL /"11" parameter if it points to ID:2016 onLook?
You would use target.type. I believe that will find the subtype of fluid.

and how do I remove the pool when the vial absorbs it?
The same as you would remove any item. target:remove()

This is intended for "vial of blood". If it is possible that the empty vial can convert into "vial of blood" when absorbing floor blood or a corpse with <attribute key="fluidSource" value="blood" /> would be great
A couple of simple if statements should get you there.
Lua:
itemType:isCorpse()

Edit: I'm trying to create the pits of inferno gravestone too, have a mess with it but guess this is a good hint of how to do it??
Lua:
local function graveStoneTeleport(cid, fromPosition, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    player:teleportTo(toPosition)
    player:say('Muahahahaha..', TALKTYPE_MONSTER_SAY, false, player)
    fromPosition:sendMagicEffect(CONST_ME_DRAWBLOOD)
    toPosition:sendMagicEffect(CONST_ME_MORTAREA)
end

If id:13070 = "vial of blood", I must use item.id == 13070 or item.id == 2610 and item.type == FLUID_BLOOD?
Lua:
                if item.id == 13070 and target.actionid == 2023 then
                toPosition.y = toPosition.y + 1
                local creatures, destination = Tile(toPosition):getCreatures(), Position(1296, 808, 10)
                if #creatures == 0 then
                    graveStoneTeleport(player.uid, fromPosition, destination)
                else
                    local creature
                    for i = 1, #creatures do
                        creature = creatures[i]
                        if creature and creature:isPlayer() then
                            graveStoneTeleport(creature.uid, toPosition, destination)
                        end
                    end
                end


Tried to guide myself with this too, without success

Thanks in advance!
Regards
Your code is a bit confusing here.
You'd have to post your full current script and a description of what you want to happen in the script.
 
@Xikini I posted a mess xD
For the empty_vial.lua with the changes you say, would be something like this? Using elseif to add a different vials?.

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.itemid(2016, 11)
then --------- check if is a pool of oil
target:remove() ----------- remove pool
item:transform(13069) ------- transform to "vial of oil"
elseif target.itemid(2016, 10) or itemType:isCorpse() ---- check if pool of blood or corpse
target:remove() ----------- remove pool
item:transform(13070) ------- transform to "vial of blood"
end
end

And for the vial_of_blood.lua, the script must do two things:
  • First, it has to drop blood same as "vial of oil" script but with blood, thats checked ;)
  • Second, if the "vial of blood" is interacting with aid:2023 and itemid:1409 do the following:
Image explaination
(check this video on 3:50)
  • how to use: player must have "vial of blood" (id:13070) and select "use with" to trigger the grave stone
  • requierements to interact: the player who drops the "vial of blood" into the gravestone must be standing inside the red cicle to trigger it, else, "you cannot use this object".
  • after using: all the players stacked inside the red circle will be teleported to 1296, 808, 10. player must say Muahahahaha.. and no liquid should be droped (cancel the first function of the script)

poi_gravestone.png

Again, thanks a lot for the help! :)
Hope I get it more clear, anything, just reply back. Regards!
 
Last edited:
@Xikini I posted a mess xD
For the empty_vial.lua with the changes you say, would be something like this? Using elseif to add a different vials?.

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.itemid(2016, 11)
then --------- check if is a pool of oil
target:remove() ----------- remove pool
item:transform(13069) ------- transform to "vial of oil"
elseif target.itemid(2016, 10) or itemType:isCorpse() ---- check if pool of blood or corpse
target:remove() ----------- remove pool
item:transform(13070) ------- transform to "vial of blood"
end
end

And for the vial_of_blood.lua, the script must do two things:
  • First, it has to drop blood same as "vial of oil" script but with blood, thats checked ;)
  • Second, if the "vial of blood" is interacting with aid:2023 and itemid:1409 do the following:
Image explaination
(check this video on 3:50)
  • how to use: player must have "vial of blood" (id:13070) and select "use with" to trigger the grave stone
  • requierements to interact: the player who drops the "vial of blood" into the gravestone must be standing inside the red cicle to trigger it, else, "you cannot use this object".
  • after using: all the players stacked inside the red circle will be teleported to 1296, 808, 10. player must say Muahahahaha.. and no liquid should be droped (cancel the first function of the script)

View attachment 63574

Again, thanks a lot for the help! :)
Hope I get it more clear, anything, just reply back. Regards!

Solved by @Xikini, full answer here
Lua:
        -- POI Gravestone
        local targetActionId = target:getActionId()
        if targetActionId == 2023 then
            local standPosition = Position(toPosition.x, toPosition.y + 1, toPosition.z)
            if player:getPosition() ~= standPosition then
                return false
            end
            local creatures = Tile(standPosition):getCreatures()
            for i = 1, #creatures do
                local _player = Player(creatures[i])
                if _player then
                    _player:teleportTo(Position(toPosition.x, toPosition.y, toPosition.z + 1))
                    _player:say('Muahahahaha..', TALKTYPE_MONSTER_SAY, false, _player)
                end
            end
            fromPosition:sendMagicEffect(CONST_ME_DRAWBLOOD)
            toPosition:sendMagicEffect(CONST_ME_MORTAREA)
            item:transform(emptyContainer)
            return true
        end
 
Note, that the above only works with the work-around bandaid solution in this thread..
So is essentially useless for most people. xD
 
Back
Top