• 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 Help with a script

Manian

User Premium
Joined
Jun 30, 2010
Messages
67
Reaction score
1
Hello,

I need help to extend a script but i really dont know too much lua, i tried to edit the script but didnt get good results, it's a fusion item script, the script make this:
you put 2 items in differents sqms, pull a lever and then a new item would be given to the player,i was wondering if its possible to make the same lever with the same action work for many items.
example: like if u put 2 boh get soft boots, if u put 2 swords get a magic sword, but all in the same script, here is the script that only work to fusion 2 item:

Code:
-- Script by Shawak   --
-- Fusion Script v1.0 --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
-----------------------------------------------------
 
firstID = 7426          -- id of the first item
secondID = 7426         -- id of the second item 
 
newID = 3961           -- id of the new item
count = 1 -- You get 1 of the new item
 
local piece1pos = {
 
	x = 1015, 
	y = 1027,    -- Position of the first item
	z = 8,
 
stackpos=1} 
local piece2pos = {
 
	x = 1015, 
	y = 1029,    -- Position of the second item
	z = 8, 
 
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)
		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 to put 2 fusionable items.")
	end
	return TRUE
end

PD: srry for my bad english :s.

11/08/2011 I STILL NEED HELP
 
Last edited:
Wouldn't know how, but I guess you could edit off of my editions.

LUA:
-- Script by Shawak   --
-- Fusion Script v1.0 --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)


local pos1 = { -- Location of FirstID
 
[1]	{x = 1015, y = 1029, z = 8}, stackpos = 1}, FirstID = 7426},
[2]	{x = 1015, y = 1029, z = 8}, stackpos = 2}, FirstID = 7426},
[3]	{x = 1015, y = 1029, z = 8}, stackpos = 3}, FirstID = 7426},
[4]	{x = 1015, y = 1029, z = 8}, stackpos = 4}, FirstID = 7426},
[5]	{x = 1015, y = 1029, z = 8}, stackpos = 5}, FirstID = 7426},

local pos2 = { -- Location of SecondID
 
[1]	{x = 1015, y = 1029, z = 8}, stackpos = 1}, SecondID = 7426},
[2]	{x = 1015, y = 1029, z = 8}, stackpos = 2}, SecondID = 7426},
[3]	{x = 1015, y = 1029, z = 8}, stackpos = 3}, SecondID = 7426},
[4]	{x = 1015, y = 1029, z = 8}, stackpos = 4}, SecondID = 7426},
[5]	{x = 1015, y = 1029, z = 8}, stackpos = 5}, SecondID = 7426},

local NewID -- New ID Of The Created Item

[1] {newID = 3961}, count = 1},
[2] newID = 3961}, count = 1},
[3] newID = 3961}, count =  1},
[4] newID = 3961}, count = 1},
[5] newID = 3961}, count = 1},

-- Functions.. LEAVE ALONE UNLESS YOU KNOW WHAT YOU ARE DOING --       
		
		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)
		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 to put 2 fusionable items.")
	end
	return TRUE
end
 
@up

Man, i really dont know anything about .lua, i tryed to make it works looking in other scripts that use the same functions, with that and with what i learned in the course of visual basic in the high school(almost nothing, i know that are very diff languages but have some things in common) and the Consol Errors i did this:

Code:
-- Script by Shawak   --
-- Fusion Script v1.0 --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)

FirstID = {
[1] = {FirstID = 7426},
[2] = {FirstID = 3961},
[3] = {FirstID = 2436},
[4] = {FirstID = 7426},
[5] = {FirstID = 7426}
}

SecondID = { 
 
[1] = {SecondID = 7426},
[2] = {SecondID = 3961},
[3] = {SecondID = 2436},
[4] = {SecondID = 7426},
[5] = {SecondID = 7426}
}
 
local pos1 = {
 
	x = 1015, 
	y = 1027,
	z = 8,
	}

local pos2 = {
 
	x = 1015,
	y = 1029, 
	z = 8,
	}

local NewID = {
 
[1] = {newID = 3961}, {count = 1},
[2] = {newID = 2436}, {count = 1},
[3] = {newID = 7424}, {count = 1},
[4] = {newID = 3961}, {count = 1},
[5] = {newID = 3961}, {count = 1}
}
 
-- Functions.. LEAVE ALONE UNLESS YOU KNOW WHAT YOU ARE DOING --    
local getpiece1 = getThingfromPos(pos1)
local getpiece2 = getThingfromPos(pos2)
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)
		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 to put 2 fusionable items.")
	end
	return TRUE
end

Im trying hard but im not getting results, i really dont know how anything about .lua programming, i would like, but i didn't find a complete tutorial(maybe i didnt search too much) the script i did doesn't give any consol errors, and dont work...

PD:SRRy for My SUX English
 
ur to
"furry fUilled" for my liking?
Get it? like miss spelling?
Anyway: syntax error's or u didn't edit sonic's right =>> Ur better off using his <<=
 
This one might work, not sure.

LUA:
-- Script by Shawak   --
-- Fusion Script v1.0 --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
 
local piece1pos = { -- Location of FirstID
 
[1] {x = 1015, y = 1029, z = 8}, stackpos = 1}, FirstID = 7426},
[2] {x = 1015, y = 1029, z = 8}, stackpos = 2}, FirstID = 7426},
[3] {x = 1015, y = 1029, z = 8}, stackpos = 3}, FirstID = 7426},
[4] {x = 1015, y = 1029, z = 8}, stackpos = 4}, FirstID = 7426},
[5] {x = 1015, y = 1029, z = 8}, stackpos = 5}, FirstID = 7426},
 
local piece2pos = { -- Location of SecondID
 
[1] {x = 1015, y = 1029, z = 8}, stackpos = 1}, SecondID = 7426},
[2] {x = 1015, y = 1029, z = 8}, stackpos = 2}, SecondID = 7426},
[3] {x = 1015, y = 1029, z = 8}, stackpos = 3}, SecondID = 7426},
[4] {x = 1015, y = 1029, z = 8}, stackpos = 4}, SecondID = 7426},
[5] {x = 1015, y = 1029, z = 8}, stackpos = 5}, SecondID = 7426},
 
local NewID -- New ID Of The Created Item
 
[1] {newID = 3961}, count = 1},
[2] {newID = 3961}, count = 1},
[3] {newID = 3961}, count = 1},
[4] {newID = 3961}, count = 1},
[5] {newID = 3961}, count = 1},
 
-- Functions.. LEAVE ALONE UNLESS YOU KNOW WHAT YOU ARE DOING --       
 
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)
		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 to put 2 fusionable items.")
	end
	return TRUE
end
 
I made some corrections with the console errors

Code:
-- Script by Shawak   --
-- Fusion Script v1.0 --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
 
local piece1pos = { -- Location of FirstID
 
[1] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {firstID = 7426},
[2] = {x = 1015, y = 1029, z = 8, stackpos = 2}, {firstID = 3961},
[3] = {x = 1015, y = 1029, z = 8, stackpos = 3}, {firstID = 2436},
}
 
local piece2pos = { -- Location of SecondID
 
[1] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {secondID = 7426},
[2] = {x = 1015, y = 1029, z = 8, stackpos = 2}, {secondID = 3961},
[3] = {x = 1015, y = 1029, z = 8, stackpos = 3}, {secondID = 2436},
}
 
local NewID = {
 
[1] = {NewID = 3961}, {count = 1},
[2] = {NewID = 2436}, {count = 1},
[3] = {NewID = 7424}, {count = 1},
}
 
-- Functions.. LEAVE ALONE UNLESS YOU KNOW WHAT YOU ARE DOING --       
 
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)
		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 to put 2 fusionable items.")
	end
	return TRUE
end

But now it gives this error:

Code:
[Error - Action Interface]
data/actions/scripts/fusion.lua:onUse
Description:
<luaGetThingFromPos> Tile not found
 
Use stackpos=1 on all positions since I assume you don't want to stack items on each other

Code:
local piece1pos = { -- Location of FirstID
 
[1] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {firstID = 7426},
[2] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {firstID = 3961},
[3] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {firstID = 2436},
}
 
local piece2pos = { -- Location of SecondID
 
[1] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {secondID = 7426},
[2] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {secondID = 3961},
[3] = {x = 1015, y = 1029, z = 8, stackpos = 1}, {secondID = 2436},
 
Back
Top