Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by akroma222 »

Hellooo!
I require a bit of direction here folks...
I have 3 alcoves and 3 gems (red, green and blue) with 2 secret doors nearby. I want there to be 2 different combinations (of coloured gems in alcoves) to open the secret doors.
So far, I have set up 1 script for each alcove for 1 combination (for example):
SpoilerShow
function gemCheckRed()
local itemFound = false
for i in alcoveGemSecret1:containedItems() do
if i .name == "red_gem" then
itemFound = true
end
end
if itemFound then
gemCounter:increment()
end
end
and these scripts are connected to a counter set to 3 (event>activate, action>increment) and also to the appropriate script (event>any, action>red gem check). The counter is then connected to a secret door.
The secret door wont open.

Any help would be muchly appreciated. I have never modded or scripted anything before so this learning curve has been quite steep.
Thank you!!!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by Komag »

You're starting with a VERY complex scripting puzzle here. It would take me a while to figure this one out, so I'm not going to do it right now, but I would suggest you practice some simpler versions of what you want and make sure each step works before adding another aspect. Also, add in "print" commands at different points and see if they happen, which will help you "debug" the process.
Finished Dungeons - complete mods to play
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by akroma222 »

Hahaha! Cheers man, I am fairly out of my depth here, I am not a modders/programmers bootlace..... I don't even know how unreasonable the questions I am asking are!! LOL
Ta for the debugging advice, let me know if you stumble upon something of a similar vein ;)
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by Komag »

Oh I'm sure what you want can be done, it's just a matter of getting a strong grasp on how everything really works under the hood first by learning other examples
Finished Dungeons - complete mods to play
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by crisman »

I did the same puzzle, but with 4 gems and 7 alcoves.
And I've used two script, one complicate, and a simple one.
it was the second puzzle I've worked on... and it's pretty complicated, yes.
Probably now I think I'll write it in another way, but it's working, so I won't rewrite it... (any suggestion are accepted thought!)
Here how I made it:
SpoilerShow
function doorOpen()

for i in alcoveRed:containedItems() do
if i.name == "red_gem" then
for i in alcoveGreen:containedItems() do
if i.name == "green_gem" then
for i in alcoveYellow:containedItems() do
if i.name == "yellow_gem" then
for i in alcoveBlue:containedItems() do
if i.name == "blue_gem" then
door:open()
end
end
end
end
end
end
end
end

end
This is the simpliest one.
Remember to connect the alcove, and check Always on and the type of action should be "any"

the complex one require only one object on the alcove (the one above just check if there is the desiderd item), but you can freely place something else on the others. The important is that the right alcoves there are only the correct gems.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by akroma222 »

Delightful!! Works like a charm :) Many thanks Crisman, that code if fairly simple indeed (even I know what's going on!) hehehe

Scripting and coding is so foreign to me, but a few days in and I am managing some nifty puzzles..... The problem is my creativity seems to be exceeding my skill in making it all happen lol :?

Thanks to both of you!!
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by Filipsan »

Try this :)

Code: Select all


function testAlcove()

	local red_gem_in = hasItem(alcoveRed,"red_gem")
    local green_gem_in = hasItem(alcoveGreen,"green_gem")
    --yellow_gem_in = hasItem(alcoveYellow,"yellow_gem")
    local blue_gem_in = hasItem(alcoveBlue,"blue_gem")

    print("red: " .. tostring(red_gem_in))
	print("green: " .. tostring(green_gem_in))
	print("blue: " .. tostring(blue_gem_in))

    if(red_gem_in and green_gem_in and blue_gem_in) then
		dungeon_door_iron_1:open()
	else
		dungeon_door_iron_1:close()
	end
end

function hasItem(alcove,item_name)
	if( alcove:getItemCount() == 1) then
		for i in alcove:containedItems() do
			if i.name == item_name then
				return true
			end
		end
	end
	return false
end

EDIT: Added prints, added item count check
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Help Req! - 3 gems(r/g/b)-3 alcoves-2 doors(diff combos)

Post by crisman »

akroma222 wrote:Delightful!! Works like a charm :) Many thanks Crisman, that code if fairly simple indeed (even I know what's going on!) hehehe

Scripting and coding is so foreign to me, but a few days in and I am managing some nifty puzzles..... The problem is my creativity seems to be exceeding my skill in making it all happen lol :?

Thanks to both of you!!
No problem!! Glad it helped!
@filipsan
Ah, that's a good one!
I've programmed this puzzle when I knew only if statement :D
(the for statement didn't understand what is was doing at the time, but it was working, and that was enough)
Post Reply