• 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.

Action [0.4] Simple Bridge Lever

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
Hello,

Another basic script for some people who are unable to create them.


data/actions/scripts/script.lua

Code:
local t = {
    [3000] = { -- UniqueID of the switch/lever
        405, -- ground tile ID
        {x = 100, y = 100, z = 7}, -- relocate position (creatures and items will be moved here)
        {x = 100, y = 100, z = 7}, -- tile positions start here
        {x = 100, y = 100, z = 7},
        {x = 100, y = 100, z = 7},
        {x = 100, y = 100, z = 7}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local v = t[item.uid]
    if v then
        for i = 3, #v do
            v.stackpos = 0
            local k = getThingFromPos(v).uid
            if k ~= 0 then
                doRelocate(v, v[2])
                doRemoveItem(k)
            else
                doCreateItem(v[1], 1, v)
            end
        end
    end

    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Credits: JDB & Cykotitan.
 
Last edited:
PLX HOW TO CONFIGURE? :p

Great script, hopefully it's easy enough so that people with a third grade mentality can use.
 
In case you don't want any errors:
Lua:
local t = {
	[3000] = { -- UniqueID of the switch/lever
		405, -- ground tile ID
		{x = 100, y = 100, z = 7}, -- relocate position (creatures and items will be moved here)
		{x = 100, y = 100, z = 7}, -- tile positions start here
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.uid]
	if v then
		for i = 3, #v do
			v[i].stackpos = 0
			local k = getThingFromPos(v[i]).uid
			if k ~= 0 then
				doRelocate(v[i], v[2])
				doRemoveItem(k)
			else
				doCreateItem(v[1], 1, v[i])
			end
		end
	end
 
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
I created a script like this a while back with animations as well, one thing you may want to consider is how to handle having a creature or player on the bridge. :p
 
nice work!
2.jpg
3.jpg
6.jpg
wanhuan1-2.jpg
 
Back
Top