• 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] Making sugar oat

SaintSeiya

New Member
Joined
Jan 3, 2015
Messages
27
Reaction score
0
Hi guys, I tried to make a script that makes sugar oat.

After clicking on Bunch of Sugar cane, click on Use With and choose bunch of wheat and it will make Sugar Oat.
Then, those 2 items will make sugar oat = (13939)

Sugar Oat (13939) = Bunch of Sugar cane (5467) + Bunch of wheat (2694)

That's what I have (data/actions/sugaroat.lua) , i don't know what else can I do :/

Code:
function onUse()
local player = Player(cid)
local useItem = Item(item)
local targetItem = Item(itemEx)
if targetItem:getId() == 5467 then
    useItem:remove()
    targetItem:remove()
    player:addItem(13939, 1)
end

Line in actions.xml
Code:
 <action itemid="2694"  script="other/sugaroat.lua"/>
 
actions.xml
Code:
<action itemid="5467" script="other/sugaroat.lua" />
sugaroat.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
     local player = Player(cid)
     if itemEx.itemid == 2694 then
         if toPosition.x ~= CONTAINER_POSITION then
             Game.createItem(13939, 1, toPosition)
         else
             player:addItem(13939, 1)
             toPosition = player:getPosition()
         end
         toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)  
         Item(item.uid):remove(1)
         Item(itemEx.uid):remove(1)
     end
     return true
end

You can use compat.lua and luascript.cpp to find functions.
https://github.com/otland/forgottenserver/blob/1.0/data/compat.lua
https://github.com/otland/forgottenserver/blob/1.0/src/luascript.cpp

You can find the main functions with the parameters, like function onUse, in other Lua scripts in that folder incase you don't know them yet.
 
Last edited:
actions.xml
Code:
<action itemid="5467" script="other/sugaroat.lua" />
sugaroat.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
     local player = Player(cid)
     if itemEx.itemid == 2694 then
         if toPosition.x ~= CONTAINER_POSITION then
             Game.createItem(13939, 1, toPosition)
         else
             player:addItem(13939, 1)
             toPosition = player:getPosition()
         end
         toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE) 
         Item(item.uid):remove(1)
         Item(itemEx.uid):remove(1)
     end
     return true
end

You can use compat.lua and luascript.cpp to find functions.
https://github.com/otland/forgottenserver/blob/1.0/data/compat.lua
https://github.com/otland/forgottenserver/blob/1.0/src/luascript.cpp

You can find the main functions with the parameters, like function onUse, in other Lua scripts in that folder incase you don't know them yet.

Thanks a lot! It worked! :D I will use it!
 
Back
Top