How to script torch holders?
Posted: Mon Oct 27, 2014 10:33 pm
I looked the forums but still didn't quite find how to make a door open by checking if there is a torch in the torch holder.
Official Legend of Grimrock Forums
http://almosthumangames.com/forum/
Code: Select all
if t1.controller:HasTorch() == true then
d1.door:open()
else
d1.door:close()
end
Code: Select all
t1.controller:getHasTorch()
Code: Select all
function torchDoor()
if counter_1.counter:getValue() == 1 then
dungeon_door_portcullis_1.door:open()
else
dungeon_door_portcullis_1.door:close()
end
end
actually it's not about being begginer but sometimes it could be pretty hard estimate what name guys from AM used until we don't have documentation yetobject71 wrote:I knew that I could get the value with a counter and so on but wanted to see how to do it with a single script. The thing is I'm trying to learn scripting (I'm a begginer programer and I'm on a pretty basic lvl) I was missing that the code is actually "getHasTorch"
I would also like to know how to Script a Torch Puzzle with lua guys. I have 8 x torches in a room each one will either need a torch or wont. Log 1 it was easy but now the code does not work anymore in Log 2object71 wrote:still in the LoG2 editor there is some kind of difference and I can't do it
it sais "attempt to call method 'hasTorch' (a nil value)"Code: Select all
if t1.controller:HasTorch() == true then d1.door:open() else d1.door:close() end
Code: Select all
--- Torch holder set: onremoveItem
--- false = Door will open or
--- Torch holder set: onInsertItem
--- true = Door will open
function TorchTestb()
if t1.controller:getHasTorch() == false then
dungeon_secret_door_10.door:open()
else
dungeon_secret_door_10.door:close()
end
end
function TorchTestc()
if t1.controller:getHasTorch() == true then
dungeon_secret_door_10.door:open()
else
dungeon_secret_door_10.door:close()
end
end
--- If it do this with 2 x Torches it wont work.
--- It comes up with Error: unexpected symbol near 'if'
function TorchPuzzle1()
if t1.controller:getHasTorch() == true and
if t2.controller:getHasTorch() == true then ---Error is here---
dungeon_secret_door_10.door:open()
else
dungeon_secret_door_10.door:close()
end
end
Code: Select all
function TorchPuzzle1()
if t1.controller:getHasTorch() and t2.controller:getHasTorch() then
dungeon_secret_door_10.door:open()
else
dungeon_secret_door_10.door:close()
end
end