• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

"Fusion" Item + Item = New Item

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,985
Solutions
2
Reaction score
121
Location
Germany
GitHub
Shawak
Hello,
Here is my litle "Fusion" Script, I hope you like it :).
Testet with TFS 0.3.4.

How it works?




You put one item on the first position, and one at the second position.
Then you turn the lever and get a new item.

How to Install?

create a fusion.lua in
data/actions/scripts
LUA:
-- Script by Shawak   --
-- Fusion Script v1.0 --

function onUse(cid, item, fromPosition, itemEx, toPosition)
-----------------------------------------------------

firstID = ITEMID          -- id of the first item
secondID = ITEMID         -- id of the second item 

newID = ITEMID           -- id of the new item
count = 1                -- You get 1 of the new item

local piece1pos = {

	x = xxx, 
	y = yyy,    -- Position of the first item
	z = z,

stackpos=1} 
local piece2pos = {

	x = xxx, 
	y = yyy,    -- Position of the second item
	z = z, 

-----------------------------------------------------
stackpos=1}
local getpiece1 = getThingfromPos(piece1pos)
local getpiece2 = getThingfromPos(piece2pos)
local playerpos = getPlayerPosition(cid)
	if getpiece1.itemid == firstID and getpiece2.itemid == secondID or getpiece1.itemid == secondID and getpiece2.itemid == firstID then 
		if item.itemid == 1945 then
			doTransformItem(item.uid,item.itemid+1)
		elseif item.itemid == 1946 then	
			doTransformItem(item.uid,item.itemid-1)
		end
		doRemoveItem(getpiece1.uid,1) 
		doRemoveItem(getpiece2.uid,1) 
		doSendMagicEffect(piece1pos,2) 
		doSendMagicEffect(piece2pos,2) 
		doPlayerAddItem(cid,newID,count)
		doSendMagicEffect(playerpos,14) 
		doPlayerSendTextMessage(cid, 22, "You have found " .. getItemArticleById(newID) .. " " .. getItemNameById(newID) .. ".")
		end
        else
                doPlayerSendTextMessage(cid, 22, "You need " .. getItemArticleById(firstID) .. " "..getItemNameById(firstID).." and " .. getItemArticleById(secondID) .. " "..getItemNameById(secondID)..".")
	end
	return TRUE
end

then goto data/actions/actions.xml
and write before the "</actions>"
LUA:
	<action actionid="8000" script="fusion.lua" />

Any bugs? Post them!
Enjoy :).

Regards,
Shawak
 
Last edited:
hi, you can use getItemNameById(uid)

LUA:
doPlayerSendTextMessage(cid, 22, "You found a "..getItemNameById(firstID).."."))

i think people will like more, if you make it advanced (:
 
This is an old ass script - ever heard of RUNE MERGER? This is just way more simple than rune merger script xD
 
But perhaps some peopel need it or want use it :).


@ Yakushi
Sounds nice but what item you get?? Can that be a worse item than the others??

You can choose,

fierstID + secondID = new ID
item + item = new item

just change the ID's.

Regards,
Shawak
 
i think this amazing bug look
LUA:
                if item.itemid == 1946 then
                        doTransformItem(item.uid,item.itemid+1)
                end
                elseif item.itemid == 1946 then
                        doTransformItem(item.uid,item.itemid-1)
                end
mayby can use item.itemid 1945 this is my sugestion
 
i think this amazing bug look
LUA:
                if item.itemid == 1946 then
                        doTransformItem(item.uid,item.itemid+1)
                end
                elseif item.itemid == 1946 then
                        doTransformItem(item.uid,item.itemid-1)
                end
mayby can use item.itemid 1945 this is my sugestion

Fixed.
 
Lol, learn how to use "end" & "elseif".

Mine fixed, improved and tabbed one:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		firstID = ITEMID,
		secondID = ITEMID,
		newID = ITEMID,
		newIDcount = COUNT,
		firstItemPosition = {x = XXXX, y = YYYY, z = Z, stackpos=1},
		secondItemPosition = {x = XXXX, y = YYYY, z = Z, stackpos=1},
		getFirstItem = getThingFromPos(firstItemPosition),
		getSecondItem = getThingFromPos(secondItemPosition)
		}
	if(getFirstItem.itemid == firstID and getSecondItem.itemid == secondID or getFirstItem.itemid == secondID and getSecondItem.itemid == firstID) then
		if(item.itemid == 1945) then
			doTransformItem(item.uid, item.itemid+1)
		elseif(item.itemid == 1946) then
			doTransformItem(item.uid, item.itemid-1)
		end
		doRemoveItem(getFirstItem.uid, 1)
		doRemoveItem(getSecondItem.uid, 1)
		doSendMagicEffect(firstItemPosition, 2)
		doSendMagicEffect(secondItemPosition, 2)
		doPlayerAddItem(cid, newID, newIDcount)
		doSendMagicEffect(fromPosition, 14)
		doPlayerSendTextMessage(cid, 22, "You have found " .. getItemArticleById(newID) .. " " .. getItemNameById(newID) .. "."))
	else
		doPlayerSendTextMessage(cid, 22, "You need " .. getItemArticleById(firstID) .. " "..getItemNameById(firstID).." and " .. getItemArticleById(secondID) .. " "..getItemNameById(secondID)..".")
	end
	return TRUE
end
 
Lol, learn how to use "end" & "elseif".

Mine fixed, improved and tabbed one:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		firstID = ITEMID,
		secondID = ITEMID,
		newID = ITEMID,
		newIDcount = COUNT,
		firstItemPosition = {x = XXXX, y = YYYY, z = Z, stackpos=1},
		secondItemPosition = {x = XXXX, y = YYYY, z = Z, stackpos=1},
		getFirstItem = getThingFromPos(firstItemPosition),
		getSecondItem = getThingFromPos(secondItemPosition)
		}
	if(getFirstItem.itemid == firstID and getSecondItem.itemid == secondID or getFirstItem.itemid == secondID and getSecondItem.itemid == firstID) then
		if(item.itemid == 1945) then
			doTransformItem(item.uid, item.itemid+1)
		elseif(item.itemid == 1946) then
			doTransformItem(item.uid, item.itemid-1)
		end
		doRemoveItem(getFirstItem.uid, 1)
		doRemoveItem(getSecondItem.uid, 1)
		doSendMagicEffect(firstItemPosition, 2)
		doSendMagicEffect(secondItemPosition, 2)
		doPlayerAddItem(cid, newID, newIDcount)
		doSendMagicEffect(fromPosition, 14)
		doPlayerSendTextMessage(cid, 22, "You have found " .. getItemArticleById(newID) .. " " .. getItemNameById(newID) .. "."))
	else
		doPlayerSendTextMessage(cid, 22, "You need " .. getItemArticleById(firstID) .. " "..getItemNameById(firstID).." and " .. getItemArticleById(secondID) .. " "..getItemNameById(secondID)..".")
	end
	return TRUE
end

I learned "end" & "elseif" already, sorry for a wrong "end" :thumbup:.

@script: Fixed.
 
^^,
I failed either. I have made config, but I had forgotten to change all integers to "config.name" :<
 
Then learn the "config." :p.
This was one of my first script that i made ;).
(Bugs because I changed some things before i posted)

Regards,
Shawak
 
LUA:
local config = {
	recipes = {
		6664,
		6665
	},
	positions = {
		{x = XXXX, y = YYYY, z = Z, stackpos = 255},
		{x = XXXX, y = YYYY, z = Z, stackpos = 255}
	},
	newItem = {6666, 1} -- {id, count}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local items = {}
	for i = 1, #config.positions do
		local recipe = getThingFromPos(config.positions[i])
		if isInArray(config.recipes, recipe.itemid) then
			table.insert(items, recipe)
			table.remove(config.recipes, table.find(config.recipes, recipe.itemid))
		else
			local recipeString = "You need ".. getItemArticleById(config.recipes[1]) .." ".. getItemNameById(recipe.itemid)
			for r = 2, #config.recipes do
				recipeString = recipeString ..", ".. getItemArticleById(config.recipes[r]) .." ".. getItemNameById(config.recipes[r])
			end
			doPlayerSendTextMessage(cid, 22, recipeString ..".")
			
			return FALSE
		end
	end
	
	if item.itemid == 1945 then
		doTransformItem(item.uid, item.itemid + 1)
	elseif item.itemid == 1946 then
		doTransformItem(item.uid, item.itemid - 1)
	end
	
	for item = 1, #items do
		doRemoveItem(items[item].uid, 1)
		doSendMagicEffect(getThingPos(items[item]), 2)
	end

	doPlayerAddItem(cid, unpack(config.newItem))
	doSendMagicEffect(fromPosition, 14)
	doPlayerSendTextMessage(cid, 22, "You have found ".. config.newItem[2] .." ".. getItemArticleById(config.newItem[1]) .. " " .. getItemNameById(config.newitem[1]) .. ".")

	return TRUE
end
Not tested but should pwns :)
 
*Other script :o
*Same result <_<

Why you maked it?


PS:
script fix.
[count]

Regards,
Shawak
 
*Other script :o
*Same result <_<

You're just jealous :)

So you mean if your script is sucky he doesn't need to improve it, totally use less because it will give the same result aye?

Actually it doesn't give the same result. It might show you the same messages and w/e, but aside from that it's not. It will take more time to process, also your code could contain the least memory leaks or simply just messy code that would be hard for other people to edit.
 
Would this work on 0.2.2 too? [8.42]


Edit: ey this shit doesnt work!

Hello?! Omg.. theres nothing.. I used this switch and nothing happend lol? Not even an error in the gui!
 
Last edited:
nice on ill use this on my serv! keep up the good work (btw your vip script is sweet also) :p
 
Back
Top