• 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 Forging Problem

  • Thread starter Thread starter Deleted member 49793
  • Start date Start date
D

Deleted member 49793

Guest
Hey guys i have a script which is ment to take 2 items and turn them into 1 with the pull of a lever and im getting this script:

Code:
[Error - Action Interface]
data/actions/scripts/forging.lua
Description:
data/actions/scripts/forging.lua:2: table index is nil
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/forging.lua)

This is the script:

Code:
local config = {
	[FIRSTITEM] = {x = 100, y = 1104, z = 8},
	[SECONDITEM] = {x = 100, y = 100, z = 8}
}

local new_item = {
	[ITEM] = {x = 100, y = 100, z = 8}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = config[item.itemid]
	for i = 1, 2 do
		local check = getThingFromPos(v[1][i], v)
		if check.itemid == v then
			local c = new_item[item.itemid]
			local c_check = getThingFromPos(c[1], c)
			if c_check.itemid <= 0 then
				doCreateItem(c, 1, c[1])
				doRemoveItem(check[i].uid, 1)
				doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
				break
			else
				return doPlayerSendCancel(cid, "The item is already there.")
			end
		else
			return doPlayerSendCancel(cid, "The items are not correct.")
		end
	end

	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Code:
        positionOfTheItem = {x=208, y=44, z=7, stackpos=1} -- Position of the item, to be removed
        positionOfTheItem2 = {x=208, y=45, z=7, stackpos=1} -- Position of the item, to be removed
        positionOfNew = {x=207, y=44, z=7, stackpos=1} -- Position item being created
        function onUse(cid, item, frompos, item2, topos)
            getItem = getThingfromPos(positionOfTheItem)
            getItem2 = getThingfromPos(positionOfTheItem2)
            if (getItem.itemid == [COLOR="red"][COLOR="red"]XXXX[/COLOR][/COLOR]) and (getItem2.itemid == [COLOR="red"]XXXX[/COLOR]) then
                if (doRemoveItem(getItem.uid, amount) == LUA_NO_ERROR) and (doRemoveItem(getItem2.uid, amount) == LUA_NO_ERROR) then
                    doCreateItem([COLOR="purple"]XXXXX[/COLOR], 1, positionOfNew)
                    if item.itemid == 1945 then
                        doTransformItem(item.uid, item.itemid+1)
                    else
                        doTransformItem(item.uid, item.itemid-1)
                    end
                else
                    doPlayerSendCancel(cid, "You need more eggs.")
                end
            else
                doPlayerSendCancel(cid, "You must place the right item on the basin.") -- Msg the player will receive if don't have the required item
            end
            return true
        end
i just ripped down a script i had so im not sure if itll work. try this and change the red X's to the items that are to be removed. the purple X's to the id of the new item.
 
Code:
---[[
	/////////////////////////////////////README///////////////////////////////////////
	//                 To make a new line Item set in itemArray                     //
	//     just copy and paste this line after the first line in itemArray          //
	//                      [{xxxx, yyyy}] = {newItem = zzzz},                      //
	//replace xxxx and yyyy fro the items needed and zzzz for the item to be created//
	//////////////////////////////////////////////////////////////////////////////////
																					  ]]--
local cfg = {
	pos1 = {x = 100, y = 100, z = 8, stackpos = 2}, --Change the positions, newpos is here the new item is going to appear.
	pos2 = {x = 100, y = 100, z = 8, stackpos = 2},
	newpos = {x = 100, y = 100, z = 8, stackpos = 2}
}
local itemArray = {
	[{xxxx, yyyy}] = {newItem = zzzz},
	[{xxxx, yyyy}] = {newItem = zzzz}
	}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	for _, var in pairs(itemArray) do
		if getThingFromPos(cfg.pos1).itemid == _[1] and getThinFromPos(cfg.pos2).itemid == _[2] then
			doCreateItem(var.newItem, 1, cfg.newpos)
			doCreatureSay(cid, "You made "..getItemNameById(var.newItem)..".", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
			for i = 1, 2 do
				remove = {getThingFromPos(cfg.pos1).uid, getThingFromPos(cfg.pos2).uid}
				doRemoveItem(remove[i])
			end	
		else
			doPlayerSendCancel(cid, "Wrong Items, Wrong Position or there is nothing there.")
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
that's looks similar to the full version of my merging script except mine works off of multiply levers and urs works on only 1 lever. but i still like your script and it gives me an idea. thanks XD im going to take that myself and use it in another part of my server
 
that's looks similar to the full version of my merging script except mine works off of multiply levers and urs works on only 1 lever. but i still like your script and it gives me an idea. thanks XD im going to take that myself and use it in another part of my server
yea sure but test it extensively, because even I'm dubious about some parts of the script.
 
ya np. im actually going to edit it some still but i like the idea of 1 lever causing multiply types of merges
 
Code:
--[[
	/////////////////////////////////////README///////////////////////////////////////
	//                 To make a new line Item set in itemArray                     //
	//     just copy and paste this line after the first line in itemArray          //
	//                      [{xxxx, yyyy}] = {newItem = zzzz},                      //
	//replace xxxx and yyyy fro the items needed and zzzz for the item to be created//
	//////////////////////////////////////////////////////////////////////////////////
																					  ]]--
local cfg = {
	pos1 = {x = 100, y = 100, z = 8, stackpos = 2}, --Change the positions, newpos is here the new item is going to appear.
	pos2 = {x = 100, y = 100, z = 8, stackpos = 2},
	newpos = {x = 100, y = 100, z = 8, stackpos = 2}
}
local itemArray = {
	[{xxxx, yyyy}] = {newItem = zzzz},
	[{xxxx, yyyy}] = {newItem = zzzz}
	}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	for _, var in pairs(itemArray) do
		if getThingFromPos(cfg.pos1).itemid == _[1] and getThinFromPos(cfg.pos2).itemid == _[2] then
			doCreateItem(var.newItem, 1, cfg.newpos)
			doCreatureSay(cid, "You made "..getItemNameById(var.newItem)..".", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
			for i = 1, 2 do
				remove = {getThingFromPos(cfg.pos1).uid, getThingFromPos(cfg.pos2).uid}
				doRemoveItem(remove[i])
			end	
		else
			doPlayerSendCancel(cid, "Wrong Items, Wrong Position or there is nothing there.")
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top