A newcomer needs scripting help beyond my powers

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

A newcomer needs scripting help beyond my powers

Post by msyblade »

Edit: Grimwold is a scripting ninja, fixed it, and explained it, to boot!

We have a new arrival beginning to learn the scripting and editor. He's got a good grasp of it, but needs a fairly complex script for a puzzle that I tried to help him with. I dont have my cpu for the next couple of days, and just wrote him a script to alter, that I can't debug myself right now., it doesn't work. If you wanna help the guy out, here's the script he has so far.
SpoilerShow
for i in dungeon_alcove_1:containedItems() do
if i.name == "blue_gem" and
for i in dungeon_alcove_4:containedItems() do
if i.name == "red_gem" and
for i in dungeon_alcove_5:containedItems() do
if i.name == "green_gem" then
exitdoor:open()
break
else
for i in dungeon_alcove_2:containedItems() do
if i.name == "green_gem" and
for i in dungeon_alcove_3:containedItems() do
if i.name == "red_gem" and
for i in dungeon_alcove_5:containedItems() do
if i.name == "blue_gem" then
prizedoor:open()
break
else
spawn("poison_cloud", party.level, party.x, party.y, 0)
end
end
end
end
end
end
end
end
end
end
end
end
Sorry, the text wont stagger when I send? He wants to pull a lever to "Check" 2 sets of alcoves for 2 solutions, or hurt the party if both are wrong.His name is Redweaver and here is the thread explaining what he trying to do.

viewtopic.php?f=14&t=4437

If you can fix it up and pm him, he will be very appreciative.
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
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: A newcomer needs scripting help beyond my powers

Post by crisman »

If I understood correctly what you want to do, a possible code could be:
There are two scripts, the first one:

Code: Select all

function exit()
if dungeon_alcove_1:containedItems ~= 1 or
dungeon_alcove_5:containedItems ~= 1 or
dungeon_alcove_4:containedItems ~= 1 then
return
end

for i in dungeon_alcove_1:containedItems() do
 if i.name ~= "blue_gem" then
return
end
end

for i in dungeon_alcove_4:containedItems() do
if i.name ~= "red_gem" then
return
end
end

for i in dungeon_alcove_5:containedItems() do
     if i.name ~= "green_gem" then
return
end
end
      exitdoor:open()
end
the second one is similar, just change the gems and numbers correctly.
I don't understand when the poison cloud must spawn thought! Can you be more specific, please? :)
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: A newcomer needs scripting help beyond my powers

Post by Grimwold »

I posted a solution on the original thread, with a little discussion of what the parts of my script did:
viewtopic.php?f=14&t=4437&p=46024#p46020

I assumed the poison should only spawn if all 3 gems were inserted and the combination was incorrect.
Post Reply