Made this with a lever id 1945, but you can use the core part of the script to see how it's done.
I'm almost sure that this will work, didn't test it.
local area = {
fromPos = {x = , y = , z = },
toPos = {x = , y = , z = }
}
function onUse(player, item, frompos, item2, topos)
if...