• 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 [Lever help needed]

Toitsss

New Member
Joined
Sep 15, 2008
Messages
47
Reaction score
0
Hello, as im scripting my levers,i followed this style
Code:
function onUse(cid, item, frompos, item2, topos)
statuepos1 = {x=484, y=506, z=6, stackpos=1}
statuepos2 = {x=485, y=506, z=6, stackpos=1}
statue1 = getThingfromPos(statuepos1)
statue2 = getThingfromPos(statuepos2)
if item.itemid == 1945 and item.uid == 1111 then
doRemoveItem(statue1.uid,1547)
doRemoveItem(statue2.uid,1547)
elseif(item.itemid == 1946 and item.uid == 1111) then
doCreateItem(statue1.uid,1547)
doCreateItem(statue2.uid,1547)
end
end

Whats wrong ? as i tried to use them ingame ,some of them work only once but others dont even move. Do i have to add ActionId to the levers also ?
`Please help, rep++
 
tryyyyyyyyyyyy
Lua:
function onUse(cid, item, frompos, item2, topos)
local statuepos1 = {x=484, y=506, z=6, stackpos=1}
local statuepos2 = {x=485, y=506, z=6, stackpos=1}
statue1 = getThingfromPos(statuepos1)
statue2 = getThingfromPos(statuepos2)
    if item.itemid == 1945 and item.uid == 1111 and statue1.itemid == 1547 and statue2.itemid == 1547 then
        doRemoveItem(statue1.uid, 1)
        doRemoveItem(statue2.uid, 1)
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 and item.uid == 1111 and statue1.itemid == 1547 and statue2.itemid == 1547 then
        doCreateItem(statue1.uid, 1)
        doCreateItem(statue2.uid, 1)
        doTransformItem(item.uid,item.itemid-1)
    end
    return true
end

sry for i = 1 was a mistake shhhhhh! xD
 
Last edited:
Lua:
local statuepos1, statuepos2 = {x=484, y=506, z=6, stackpos=1}, {x=485, y=506, z=6, stackpos=1}
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1945 and item.uid == 1111 then
		doRemoveItem(getThingFromPos(statuepos1).uid)
		doRemoveItem(getThingFromPos(statuepos2).uid)
	elseif(item.itemid == 1946 and item.uid == 1111) then
		doCreateItem(1547, 1, statuepos1)
		doCreateItem(1547, 1, statuepos2)
	end
return true
end
 
Lua:
local statuepos1, statuepos2 = {x=484, y=506, z=6, stackpos=1}, {x=485, y=506, z=6, stackpos=1}
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1945 and item.uid == 1111 then
		doRemoveItem(getThingFromPos(statuepos1).uid)
		doRemoveItem(getThingFromPos(statuepos2).uid)
	elseif(item.itemid == 1946 and item.uid == 1111) then
		doCreateItem(1547, 1, statuepos1)
		doCreateItem(1547, 1, statuepos2)
	end
return true
end

If i used that, then the wall moved, but lever didnt move and i got this kind of erros in Console
Lua:
 [07/03/2010 17:15:57] [Error - Action Interface] 
[07/03/2010 17:15:57] data/actions/scripts/OpenStoneThing.lua:onUse
[07/03/2010 17:15:57] Description: 
[07/03/2010 17:15:57] (luaDoRemoveItem) Item not found
 
Code:
local t = {
	{{x=484, y=506, z=6}, 1547},
	{{x=485, y=506, z=6}, 1547}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Code:
local t = {
	{{x=484, y=506, z=6}, 1547},
	{{x=485, y=506, z=6}, 1547}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end


Once again, your a life saviour!
 
Yes, and you could merge them all into 1 script, example:
Code:
local t = {
	[1111] = {
		{{x=484, y=506, z=6}, 1547},
		{{x=485, y=506, z=6}, 1547}
	}[B][COLOR="Red"],
	[1112] = {
		{{x=600, y=500, z=6}, 1548},
		{{x=601, y=500, z=6}, 1548}
	}[/COLOR][/B]
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t[item.uid]) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t[item.uid]) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
[1123] = {
{{x=507, y=497, z=6}, 1396},
if its like this, do i need to have , after 1396)? if its just one coordination.
 
Yes, and you could merge them all into 1 script, example:
Code:
local t = {
	[1111] = {
		{{x=484, y=506, z=6}, 1547},
		{{x=485, y=506, z=6}, 1547}
	}[B][COLOR="Red"],
	[1112] = {
		{{x=600, y=500, z=6}, 1548},
		{{x=601, y=500, z=6}, 1548}
	}[/COLOR][/B]
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t[item.uid]) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t[item.uid]) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Only the first one works, when i merged them together.
Code:
local t = {
	[1111] = {
		{{x=484, y=506, z=6}, 1547},
		{{x=485, y=506, z=6}, 1547}
	},
	[1112] = {
		{{x=490, y=502, z=6}, 429},
	},
	[1113] = {
		{{x=484, y=499, z=6}, 405},
	
	},
	[1114] = {
		{{x=489, y=514, z=6}, 1284},
		{{x=489, y=515, z=6}, 1284}
	},
	[1115] = {
		{{x=461, y=511, z=8}, 1394},
		{{x=461, y=512, z=8}, 1394}
	},
	[1116] = {
		{{x=469, y=498, z=6}, 1798},
	},
	[1117] = {
		{{x=435, y=496, z=5}, 6740},
		{{x=436, y=496, z=5}, 6740}
	},
	[1118] = {
		{{x=437, y=488, z=5}, 405},
	},
	[1119] = {
		{{x=423, y=501, z=6}, 405},
	},
	[1120] = {
		{{x=428, y=498, z=6}, 1284},
		{{x=428, y=599, z=6}, 1284}
	},
	[1121] = {
		{{x=481, y=478, z=7}, 1534},
		{{x=481, y=479, z=7}, 1534}
	},
	[1122] = {
		{{x=502, y=486, z=7}, 1386},
	},
	[1123] = {
		{{x=507, y=497, z=6}, 405},
	
	},
	[1124] = {
		{{x=570, y=503, z=6}, 1396},
	},
	[1125] = {
		{{x=582, y=507, z=6}, 1036},
		{{x=582, y=508, z=6}, 1036},
		{{x=582, y=509, z=6}, 1036}
	},
	[1126] = {
		{{x=525, y=503, z=7}, 1386},
	},
	[1127] = {
		{{x=532, y=581, z=6}, 458},
	},
	[1128] = {
		{{x=530, y=589, z=6}, 1484},
	},
	[1129] = {
		{{x=528, y=602, z=7}, 3616},
	},
	[1130] = {
		{{x=510, y=599, z=6}, 1385},
	},
	[1131] = {
		{{x=535, y=573, z=6}, 106},
	},
	[1132] = {
		{{x=559, y=641, z=9}, 1385},
		{{x=560, y=641, z=9}, 1385},
		{{x=561, y=641, z=9}, 1385}
	},
	[1133] = {
		{{x=873, y=644, z=9}, 1385},
	},
	[1134] = {
		{{x=917, y=667, z=9}, 1546},
	},
	[1135] = {
		{{x=921, y=667, z=9}, 1546},
		{{x=925, y=667, z=9}, 1546},
	   }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t[item.uid]) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t[item.uid]) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Thats how it looks atm, whats wrong with it ?
 
Lua:
local t = {
	[1111] = {
		{{x=484, y=506, z=6}, 1547},
		{{x=485, y=506, z=6}, 1547}
	},
	[1112] = {
		{{x=490, y=502, z=6}, 429}
	},
	[1113] = {
		{{x=484, y=499, z=6}, 405}	
	},
	[1114] = {
		{{x=489, y=514, z=6}, 1284},
		{{x=489, y=515, z=6}, 1284}
	},
	[1115] = {
		{{x=461, y=511, z=8}, 1394},
		{{x=461, y=512, z=8}, 1394}
	},
	[1116] = {
		{{x=469, y=498, z=6}, 1798}
	},
	[1117] = {
		{{x=435, y=496, z=5}, 6740},
		{{x=436, y=496, z=5}, 6740}
	},
	[1118] = {
		{{x=437, y=488, z=5}, 405}
	},
	[1119] = {
		{{x=423, y=501, z=6}, 405}
	},
	[1120] = {
		{{x=428, y=498, z=6}, 1284},
		{{x=428, y=599, z=6}, 1284}
	},
	[1121] = {
		{{x=481, y=478, z=7}, 1534},
		{{x=481, y=479, z=7}, 1534}
	},
	[1122] = {
		{{x=502, y=486, z=7}, 1386}
	},
	[1123] = {
		{{x=507, y=497, z=6}, 405}	
	},
	[1124] = {
		{{x=570, y=503, z=6}, 1396}
	},
	[1125] = {
		{{x=582, y=507, z=6}, 1036},
		{{x=582, y=508, z=6}, 1036},
		{{x=582, y=509, z=6}, 1036}
	},
	[1126] = {
		{{x=525, y=503, z=7}, 1386}
	},
	[1127] = {
		{{x=532, y=581, z=6}, 458}
	},
	[1128] = {
		{{x=530, y=589, z=6}, 1484}
	},
	[1129] = {
		{{x=528, y=602, z=7}, 3616}
	},
	[1130] = {
		{{x=510, y=599, z=6}, 1385}
	},
	[1131] = {
		{{x=535, y=573, z=6}, 106}
	},
	[1132] = {
		{{x=559, y=641, z=9}, 1385},
		{{x=560, y=641, z=9}, 1385},
		{{x=561, y=641, z=9}, 1385}
	},
	[1133] = {
		{{x=873, y=644, z=9}, 1385}
	},
	[1134] = {
		{{x=917, y=667, z=9}, 1546}
	},
	[1135] = {
		{{x=921, y=667, z=9}, 1546},
		{{x=925, y=667, z=9}, 1546}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for _, v in ipairs(t[item.uid]) do
			doRemoveItem(getTileItemById(v[1], v[2]).uid)
		end
	elseif item.itemid == 1946 then
		for _, v in ipairs(t[item.uid]) do
			doCreateItem(v[2], 1, v[1])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Code:
	<action uniqueid="1111" event="script" value="OpenStoneThing.lua"/>
Thats what it looks atm, when i had all the 25 scripts seperated, then i had 25 lines in there, i dont know how to add all the unique IDs in one scriptline in actions.xml if you understand me.
 
rep ++ for both of you ! thanks, everything works fine !
Now could you help me with 1)deathloss also ? i want the lowest lvl possible to be lvl 80, If players dies at lvl 80 he gets back his lvl 80, but if player dies in like 89, he goes to 88 or something.
2)Would be possible to do !buyaddon first mage addon or so with a script ? i have them with npcs, but since my warot has like 8 towns, it would be messy.
 
Back
Top