• 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 sacrifice lever

WSouls

New Member
Joined
Aug 5, 2010
Messages
51
Reaction score
1
Code:
		uniques = {
			--[leveruid] = {item to remove, item to make} -- egg color equipemt type
			[20019] = {id = 9929, newitem = 6095, leverpos = {x = 212,y = 1214,z = 8}}, --natural to worn armor
			[20017] = {id = 9927, newitem = 6096, leverpos = {x = 212,y = 1206,z = 8}}, --natural to worm helmet
			[20021] = {id = 9928, newitem = 5918, leverpos = {x = 212,y = 1222,z = 8}}, --natural to worm legs
			[20018] = {id = 2527, newitem = 2531, leverpos = {x = 198,y = 1214,z = 8}}, --natural to worm shield
			[20020] = {id = 7697, newitem = 6093, leverpos = {x = 226,y = 1214,z = 8}}, --natural to worm ring
			[20022] = {id = 9931, newitem = 5462, leverpos = {x = 212,y = 1230,z = 8}} --natural to worm boots
		}

function onUse(cid, item, frompos, item2, topos)
	unique = uniques[item.uid]
	-- Position of the itmes to be removed
	positions = {
		getThingfromPos({x = leverpos.x-2, y = leverpos.y+1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x-2, y = leverpos.y, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x-2, y = leverpos.y-1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x-1, y = leverpos.y-1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x, y = leverpos.y-1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x+1, y = leverpos.y-1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x+2, y = leverpos.y-1, z = leverpos.z, stackpos=2}),
		getThingfromPos({x = leverpos.x+2, y = leverpos.y, z = leverpos.z, stackpos=2})
	}
	
	newpos = {x = leverpos.x, y = leverpos.y, z = leverpos.z, stackpos=2} -- Position item being created
	if (item.itemid == 1945) then
		for i = #positions, -1 do
			if positions[i] == unique.id then
				if doRemoveItem(positions[i].uid, 1) == LUA_NO_ERROR then
					pass = pass + 1
				end
			end
		end
		if pass == 8 then
			doCreateItem(2466, 1, positionOfNew)
			doTransformItem(item.uid, item.itemid+1)	
		else
			doPlayerSendCancel(cid, "Not all of the items you are sacrificing are correct.") -- Msg the player will receive if don't have the required item
		end
	elseif (item.itemid == 1946) then
			doTransformItem(item.uid, item.itemid-1)
	end
	return true
end

Code:
[19/08/2010 20:03:35] [Error - Action Interface] 
[19/08/2010 20:03:35] buffer:onUse
[19/08/2010 20:03:35] Description: 
[19/08/2010 20:03:35] [string "loadBuffer"]:15: attempt to index global 'leverpos' (a nil value)
[19/08/2010 20:03:35] stack traceback:
[19/08/2010 20:03:35] 	[string "loadBuffer"]:15: in function <[string "loadBuffer"]:11>

its suppose to check 8 positions for the correct items. it removes them and gives u a new one.
 
Lua:
local uniques = {
	--[leveruid] = {item to remove, item to make} -- egg color equipemt type
	[20019] = {id = 9929, newitem = 6095, leverpos = {x = 212,y = 1214,z = 8}}, --natural to worn armor
	[20017] = {id = 9927, newitem = 6096, leverpos = {x = 212,y = 1206,z = 8}}, --natural to worm helmet
	[20021] = {id = 9928, newitem = 5918, leverpos = {x = 212,y = 1222,z = 8}}, --natural to worm legs
	[20018] = {id = 2527, newitem = 2531, leverpos = {x = 198,y = 1214,z = 8}}, --natural to worm shield
	[20020] = {id = 7697, newitem = 6093, leverpos = {x = 226,y = 1214,z = 8}}, --natural to worm ring
	[20022] = {id = 9931, newitem = 5462, leverpos = {x = 212,y = 1230,z = 8}} --natural to worm boots
}

function onUse(cid, item, fromPosition, itemEx, toPosition)	
	if item.itemid == 1945 then
		local v = uniques[item.uid]
		-- Position of the items to be removed
		local positions, uid = {
			{x = v.leverpos.x-2, y = v.leverpos.y+1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x-2, y = v.leverpos.y, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x-2, y = v.leverpos.y-1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x-1, y = v.leverpos.y-1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x, y = v.leverpos.y-1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x+1, y = v.leverpos.y-1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x+2, y = v.leverpos.y-1, z = v.leverpos.z, stackpos=2},
			{x = v.leverpos.x+2, y = v.leverpos.y, z = v.leverpos.z, stackpos=2}
		}, {}
		for _, k in ipairs(positions) do
			local p = getThingfromPos(k)
			if p.itemid == v.id then
				table.insert(uid, p.uid)
			else
				return doPlayerSendCancel(cid, "Not all of the items you are sacrificing are correct.") -- Msg the player will receive if don't have the required item
			end
		end

		for _, k in ipairs(uid) do
			doRemoveItem(k)
		end
		doCreateItem(v.newitem, 1, v.leverpos)
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top Bottom