Hashcube
Member
- Joined
- Jun 28, 2023
- Messages
- 27
- Reaction score
- 11
Hi. I struggle to make my switch work. Tried so far a lot of scripts and wrote some code on my own but nothing worked.
What I try to achieve is if player uses switch, then door on positon XYZ transforms from closed to open.
Procedure:
1 of the scripts I tried:
source
quests/door.lua
What I try to achieve is if player uses switch, then door on positon XYZ transforms from closed to open.
Procedure:
- In RME set action id 9002 on switch
- add <action itemid="9002" script="quests/door.lua" /> to data\actions\actions.xml
1 of the scripts I tried:
source
quests/door.lua
Lua:
local doorPosition = Position(1106, 853, 12)
local relocatePosition = Position(1107, 853, 12)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1946 then
local doorItem = Tile(doorPosition):getItemById(5108)
if doorItem then
doorItem:transform(5109)
doorItem:setActionId(1002)
item:transform(1945)
end
else
local tile = Tile(doorPosition)
local doorItem = tile:getItemById(5109)
if doorItem then
tile:relocateTo(relocatePosition, true)
doorItem:transform(5108)
doorItem:setActionId(1001)
item:transform(1946)
end
end
return true
end
Last edited: