• 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 How to add Function on Item??

Binho®

KooL =D
Joined
May 27, 2008
Messages
344
Reaction score
0
Location
BrZ Style
I tried to do a script, but failed, delete it.
But then i thought, and thought best to have it.

So how do you that an item 'usable' perform/execute a function in another item.

Basic/Example script!
I have a amulet or another item usable, if i use on dead body will be something.
I have a wand (star tear), if i use on item will be something.
 
Last edited:
Use actions with the onuse function for it.

Actions on "usable" item? Or fixed items?
If is usable, i need doSetItemActionId(uid, actionid)?

LOL, edit it. :(:(

I know how to use actions with the onUse(cid) function.
I just want to know how to do that (an item with actions) can be used inside of another item.
 
Last edited:
Actions on "usable" item? Or fixed items?
If is usable, i need doSetItemActionId(uid, actionid)?

LOL, edit it. :(:(

I know how to use actions with the onUse(cid) function.
I just want to know how to do that (an item with actions) can be used inside of another item.

give some example with the id's included than I/we can show u how it works:)
 
Example...

I have a item, hmmm... star tear, ID: 7735
I want this item to remove a stone, to be used in tile special. Tile ID: 471

Then, if i use the stat tear on tile, the stone is removed.
If i use again, the stone appears.

A basic example that i will make new scripts with other item. You understand me?
 
Something similiar to:
Code:
local config = {
	stonePos = { x = x, y = y, z = z, stackpos = 1 }
}
function onUse(cid, item, itemEx)
	if itemEx.itemid == 471 then
		if getThingfromPos(config.stonePos).itemid ~= 0 then
			doRemoveItem(getThingfromPos(config.stonePos).uid)
		else
			doCreateItem(stoneid, 1, config.stonePos)
		end
	end
	return TRUE
end
 
Something similiar to:
Code:
local config = {
    stonePos = { x = x, y = y, z = z, stackpos = 1 }
}
function onUse(cid, item, itemEx)
    if itemEx.itemid == 471 then
        if getThingfromPos(config.stonePos).itemid ~= 0 then
            doRemoveItem(getThingfromPos(config.stonePos).uid)
        else
            doCreateItem(stoneid, 1, config.stonePos)
        end
    end
    return TRUE
end

Marcinek, this not work. :(
 

Nothing Rudolf... :(
See...
Code:
local config = {
    stonePos = { x = 16438, y = 15691, z = 8, stackpos = 1 }
}

function onUse(cid, item, itemEx)
    if itemEx.itemid == 471 then
        if getThingFromPos(config.stonePos).itemid ~= 0 then
            doRemoveItem(getThingFromPos(config.stonePos).uid, 1)
        else
            doCreateItem(1304, 1, config.stonePos)
        end
    end
    return TRUE
end
You post without value '1' below.
doRemoveItem(getThingfromPos(config.stonePos).uid)
getThingfromPos = getThingFromPos

I use TFS 0.3B2.
 
Last edited:
I tried with my script!
Code:
local stonePos = { x = 16438, y = 15691, z = 8, stackpos = 1 }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid == 471 then
        doRemoveItem(getThingFromPos(stonePos).uid, 1)
    end
end
And worked!
 
Back
Top