New guy with a scripting issue

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Radioactivetire
Posts: 1
Joined: Fri May 10, 2013 2:30 am

New guy with a scripting issue

Post by Radioactivetire »

Hey

So I've just started working on my first dungeon for Grimrock and I've encountered a problem I was hopping you guys would be able to help me with. The puzzle I'm working on has five levers. The first four activate a different teleporter each, but when the fifth lever is activated I want the first four levers to activate a different teleporter. Also, I want only one teleporter to be active at a time. Also there is a altar at the end containing a blue gem, and when that gem is moved, I do not want the teleporters to work anymore. To accomplish that I've added "counter_puzzle_challenge_2_1" that the first four levers increment when activated, and decrements when deactivated.

So far I've got this code:
SpoilerShow
function Puzzlechallenge_2_1 ()

for item in altar_puzzle_challenege_2:containedItems() do
if item.name == "blue_gem" then
if lever_puzzle_2_1:getLeverState() == "activated" and counter_puzzle_challenge_2_1:getValue() < "2" then
if lever_puzzle_2_s:getLeverState() == "deactivated" then
teleporter_puzzle2_1_1:activate()
teleporter_puzzle2_1_2:deactivate()
teleporter_puzzle2_1_3:deactivate()
teleporter_puzzle2_1_4:deactivate()
else
teleporter_puzzle2_1_1:deactivate()
teleporter_puzzle2_1_2:deactivate()
teleporter_puzzle2_1_3:deactivate()
teleporter_puzzle2_1_4:deactivate()
end
else
counter_puzzle_challenge_2_1:increment()
end
end
end
end
It's simplified for one lever right now, and if possible (and practical) I'd like to have one script to run all the levers. I *think* that the code is fine (basically teaching myself Lua on the go) as it doesn't return any errors, but I can't get the levers to call the function. If anyone has any idea how to fix this, I'd love the help

Thanks



PS. I apologize that I cant seem to get the spacing right on the code so here's a screen shot

http://steamcommunity.com/profiles/7656 ... reenshots/
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

Re: New guy with a scripting issue

Post by alois »

Before looking at/thinking on the script: when you check the value of a counter, do not use the "":

Code: Select all

counter_puzzle_challenge_2_1:getValue() < 2
since counters contain numbers, not strings! :)

alois :)
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: New guy with a scripting issue

Post by msyblade »

You may also try removing the underscores from the original function name. It can be a bit more choosy than the rest of the script.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Post Reply