Page 1 of 1

A newcomer needs scripting help beyond my powers

Posted: Tue Dec 04, 2012 4:07 pm
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.

Re: A newcomer needs scripting help beyond my powers

Posted: Tue Dec 04, 2012 4:58 pm
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? :)

Re: A newcomer needs scripting help beyond my powers

Posted: Tue Dec 04, 2012 5:06 pm
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.