Multiple conditions met

XanMag
I am in the midst of an all day game creation affair here, so bear with the recent stupid questions...

In my game, there are 4 conditions that need met. Four chips need to be placed in a circuit board. The chips can be placed in any order. I would like to give the option of reminding the player which chips have been accurately placed, so when the player looks at the board, they can see which shapes of chips they need to install. So, let's say there are 4 chips - A,B,C, and D. If player puts C in first, they can look at an image and see the board with chip C in place. Then they but chip A in and I would like them to be able to see the image with chip A and C in. Etc, etc. And the chips are not actually lettered - they are shapes, so it makes imaging them a little more difficult than just saying 'You have accurately installed chips A, B, and D.

Also, and more importantly, I need to know how to set a flag on the board once ALL four chips have been placed, so it can be completed and used appropriately.

There has to be an easier way than I am thinking... And in your responses... please be gentle and speak slowly (the less code heavy the better). I'm tired. :(

TM123
Are you using pics or the drawing functions?

As for the flag, maybe I don't understand, couldn't you just add 1 to a variable when each is installed, then check if it is equal to 4?

HegemonKhan
I presume you're working with an Object (your board) and placing Objects (your chips) into it.

While, using Objects isn't too much more work, it's a bit easy with using a List instead, though understanding list usage takes some time, it's not easy to learn.

Actually, even with working with Objects, you still have to work with Lists anyways, hehe, as they're the solution to your questions.

---------

the main thing you need is the way to check for what Objects (chips) are within your Object (board) and~or to display~tell~show the person the Objects (chips) that are in the Object (board), which is done via:

http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... ldren.html
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... jects.html

http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... bject.html

http://docs.textadventures.co.uk/quest/ ... count.html

http://docs.textadventures.co.uk/quest/ ... reach.html

http://docs.textadventures.co.uk/quest/ ... lists.html

and alternatives for your Player Object~s:

http://docs.textadventures.co.uk/quest/ ... ntory.html
http://docs.textadventures.co.uk/quest/ ... y/got.html

----------

and either use:

Tm123's method of an Integer Attribute, which is increased, as you move your chips into your board
~OR~
ListCount ( http://docs.textadventures.co.uk/quest/ ... count.html ) + optionally also ListContains ( http://docs.textadventures.co.uk/quest/ ... tains.html )

aka:

if (ListCount (Object_name.Object_List_Attribute_name) = 4 and ListContains (Object_name.Object_List_Attribute_name, A_chip) and ListContains (Object_name.Object_List_Attribute_name, B_chip) and ListContains (Object_name.Object_List_Attribute_name, C_chip) and ListContains (Object_name.Object_List_Attribute_name, D_chip)) {
msg ("your board has all 4 types of chips, now do what you want it to do when it has all 4 types of chips")
}

else if (ListCount (Object_name.Object_List_Attribute_name) = 4 and ListContains (Object_name.Object_List_Attribute_name, A_chip) and ListContains (Object_name.Object_List_Attribute_name, B_chip) and ListContains (Object_name.Object_List_Attribute_name, C_chip)) {
msg ("your board has 4 items, but only 3 of those items are the correct type of chips. The chip you're missing is the D_chip")
}

// etc 'else ifs'


or alternatively, you can use 'foreach' instead to cycle through your items in your list, and if they match up (or not) with your chips, doing a similiar design purpose as seen above.

XanMag
@ TM123, I am using pics.

And I guess I wouldn't need a flag set. The board is inside of a land mine. Once the four chips are installed, then it is ready to receive the 5th piece (C4) and then finally a sixth piece (a spring). At this point it will be closed again and ready for use. I can easily do the 5th and 6th step seeing that it is only one piece each (I'll just swap a new object in). My problem is setting it up so that the "code" recognizes the 4th chip is installed. I could easily force the player to but the chips in in a specific order, but that defeats the purpose of the puzzle that is set up. Also, I have 6 vehicles that need disabled (in any order) and a multi-step problem that needs solved (in any order) to complete the game... so I need to learn how to do this.

And, as long as I have been around, you'd think something this useful and obvious I'd understand by now, but...

So, I think the whole add 1 to a variable and check to see if it equals 4 is what I need, but I don't know how to do that.

EDIT ADD:

If I can figure out this little puzzle problem, that would help me tremendously. This is code I plan on putting in my tutorial room for the such a problem. I would like to use the puzzle pieces in any order to complete the puzzle. Thanks in advance.

  <object name="multiple conditions met room">
<inherit name="editor_room" />
<object name="jigsaw puzzle">
<inherit name="editor_object" />
<inherit name="surface" />
<look type="script">
</look>
<takemsg>You don't dare pick up the jigsaw puzzle. It will certainly fall apart.</takemsg>
<feature_container />
<contentsprefix>in which there are</contentsprefix>
<listchildren />
<hidechildren />
<object name="thousands of placed pieces">
<inherit name="editor_object" />
<scenery type="boolean">false</scenery>
<visible />
<takemsg>You don't want to destroy the puzzle. You want to finish it!</takemsg>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<object name="standard piece">
<inherit name="editor_object" />
<look>It's kind of square shaped with notches cut out on one side and tabs on the adjacent sides.</look>
<take type="script">
if (GetBoolean(standard piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (standard piece)
}
</take>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("You easily find the place that this puzzle piece goes.")
MoveObject (standard piece, jigsaw puzzle)
SetObjectFlagOn (standard piece, "placed")
MakeObjectInvisible (standard piece)
</item>
</selfuseon>
</object>
<object name="border piece">
<inherit name="editor_object" />
<look>Flat on one side with a standard puzzle cut on the other. It goes on the outside.</look>
<take type="script">
if (GetBoolean(border piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (border piece)
}
</take>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("Without a problem, you find where the piece goes.")
MoveObject (border piece, jigsaw puzzle)
SetObjectFlagOn (border piece, "placed")
MakeObjectInvisible (border piece)
</item>
</selfuseon>
</object>
<object name="corner piece">
<inherit name="editor_object" />
<look>It's your typical corner piece.</look>
<take type="script">
if (GetBoolean(corner piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (corner piece)
}
</take>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("In mere seconds, you connect the piece perfectly in the jigsaw puzzle.")
MoveObject (corner piece, jigsaw puzzle)
SetObjectFlagOn (corner piece, "placed")
MakeObjectInvisible (corner piece)
</item>
</selfuseon>
</object>
<object name="awkward piece">
<inherit name="editor_object" />
<look>This is one of those weird pieces that don't look typical - just an odd, irregular shape.</look>
<take type="script">
if (GetBoolean(awkward piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (awkward piece)
}
</take>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("You find a place for the awkward puzzle piece.")
MoveObject (awkward piece, jigsaw puzzle)
SetObjectFlagOn (awkward piece, "placed")
MakeObjectInvisible (awkward piece)
</item>
</selfuseon>
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<look>You're Magoo. A simple being trapped in a test game.</look>
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
</object>
</object>


So... what I did above (for practice for my big game) is this. I have four pieces. I take the standard piece. I use standard piece on puzzle. In that script, I moved standard piece to parent object puzzle. I make that piece invisible (so when you look at the puzzle you can't "see" the standard piece, only 'thousands of placed puzzle pieces' (which I already included as a child of the puzzle). I repeated with the remaining puzzle pieces. Now I just need to know how to check to see how many missing pieces remain in the puzzle and give an appropriate description of the puzzle (i.e. there appear to be 3 missing pieces; only two pieces remain; a single piece is missing; congratulation the puzzle is complete). Make sense?

Thanks again!

XanMag

HegemonKhan
sorry I totally forgot this link, it's much easier than using 'ListContains' and Lists:

http://docs.textadventures.co.uk/quest/ ... tains.html

using this as an example:

Object Name: treasure_chest
-> Object Name: candy
-> Object Name: chocolate
-> Object Name: fire_coin

if (Contains (treasure_chest, candy) and Contains (treasure_chest, chocolate) and Contains (treasure_chest, fire_coin)) {
// example, a script to show~upload: picture_1
} else if (Contains (treasure_chest, candy) and Contains (treasure_chest, chocolate)) {
// example, a script to show~upload: picture_2
} else if (Contains (treasure_chest, candy)) {
// example, a script to show~upload: picture_3
}


--------------

if your puzzle requires working with 'ListCount' (the number~amount of items~Objects in an Object), then you must use ~work wth (create and use): Lists, as you can't directly count the number~amount of (sub~child) Objects within an (parent) Object, but you can when using a List.

indirectly you can do it with an Object, via:

for example: the number~amount of Objects in~on your 'player' Player Object, aka in your 'inventory' Object List

(we're actually using a pre-built Object List, in this example, the: 'player' Player Object's Objectlist Attribute: inventory)
(so, we're really not technically using an Object at all...lol. I lied above, laughs)

count_variable = 0
foreach (object_variable, ScopeInventory) {
count_variable = count_variable + 1
}
player.number_of_objects_held = count_variable


otherwise, you got to create a List (and add your Object's names to it) ~ there's many pre-built-defined Lists too (like the 'Scopes', 'AllObjects()', and etc) so you may not need to create a list and add your object's names to it, and then you can use 'ListCount' to find the number of items in your list.

TM123

Now I just need to know how to check to see how many missing pieces remain in the puzzle and give an appropriate description of the puzzle (i.e. there appear to be 3 missing pieces; only two pieces remain; a single piece is missing; congratulation the puzzle is complete).



Here's how. Jigsaw Puzzle has MissingPieceCount integer attribute set to 4. The placing the pieces scripts have an added statement to decrease the count. The puzzle's look description is a script which changes according to MissingPieceCount. There is a change script on the puzzle "changedMissingPieceCount" (lower case "c" is a must) which prints a message telling how many pieces are missing, and finally "congratulations!" when the count is zero, and sets the puzzle.completed flag to true.

<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="puzzle">
<gameid>02d1f70c-1629-4df6-b482-019cfdaa83cd</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
</object>
<object name="multiple conditions met room">
<inherit name="editor_room" />
<object name="jigsaw puzzle">
<inherit name="editor_object" />
<inherit name="surface" />
<takemsg>You don't dare pick up the jigsaw puzzle. It will certainly fall apart.</takemsg>
<feature_container />
<contentsprefix>in which there are</contentsprefix>
<listchildren />
<hidechildren />
<MissingPieceCount type="int">4</MissingPieceCount>
<look type="script">
switch (jigsaw puzzle.MissingPieceCount) {
case (4) {
msg ("It appears to be missing four pieces.")
}
case (3) {
msg ("It appears to be missing three pieces.")
}
case (2) {
msg ("It appears to be missing two pieces.")
}
case (1) {
msg ("It is missing only one piece.")
}
case (0) {
msg ("The puzzle is completed.")
}
}
</look>
<changedMissingPieceCount type="script">
msg ("The missing piece count is now " + jigsaw puzzle.MissingPieceCount)
if (jigsaw puzzle.MissingPieceCount = 0) {
msg ("CONGRATULATIONS!! YOU HAVE COMPLETED THE PUZZLE")
SetObjectFlagOn (jigsaw puzzle, "Completed")
}
</changedMissingPieceCount>
<Completed type="boolean">false</Completed>
<object name="thousands of placed pieces">
<inherit name="editor_object" />
<scenery type="boolean">false</scenery>
<visible />
<takemsg>You don't want to destroy the puzzle. You want to finish it!</takemsg>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<object name="standard piece">
<inherit name="editor_object" />
<look>It's kind of square shaped with notches cut out on one side and tabs on the adjacent sides.</look>
<feature_usegive />
<take type="script">
if (GetBoolean(standard piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (standard piece)
}
</take>
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("You easily find the place that this puzzle piece goes.")
MoveObject (standard piece, jigsaw puzzle)
SetObjectFlagOn (standard piece, "placed")
MakeObjectInvisible (standard piece)
jigsaw puzzle.MissingPieceCount = jigsaw puzzle.MissingPieceCount - 1
</item>
</selfuseon>
</object>
<object name="border piece">
<inherit name="editor_object" />
<look>Flat on one side with a standard puzzle cut on the other. It goes on the outside.</look>
<feature_usegive />
<take type="script">
if (GetBoolean(border piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (border piece)
}
</take>
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("Without a problem, you find where the piece goes.")
MoveObject (border piece, jigsaw puzzle)
SetObjectFlagOn (border piece, "placed")
MakeObjectInvisible (border piece)
jigsaw puzzle.MissingPieceCount = jigsaw puzzle.MissingPieceCount - 1
</item>
</selfuseon>
</object>
<object name="corner piece">
<inherit name="editor_object" />
<look>It's your typical corner piece.</look>
<feature_usegive />
<take type="script">
if (GetBoolean(corner piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (corner piece)
}
</take>
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("In mere seconds, you connect the piece perfectly in the jigsaw puzzle.")
MoveObject (corner piece, jigsaw puzzle)
SetObjectFlagOn (corner piece, "placed")
MakeObjectInvisible (corner piece)
jigsaw puzzle.MissingPieceCount = jigsaw puzzle.MissingPieceCount - 1
</item>
</selfuseon>
</object>
<object name="awkward piece">
<inherit name="editor_object" />
<look>This is one of those weird pieces that don't look typical - just an odd, irregular shape.</look>
<feature_usegive />
<take type="script">
if (GetBoolean(awkward piece, "placed")) {
msg ("You have already placed this piece correctly. No need to take it out now!")
}
else {
msg ("Taken.")
AddToInventory (awkward piece)
}
</take>
<selfuseon type="scriptdictionary">
<item key="jigsaw puzzle">
msg ("You find a place for the awkward puzzle piece.")
MoveObject (awkward piece, jigsaw puzzle)
SetObjectFlagOn (awkward piece, "placed")
MakeObjectInvisible (awkward piece)
jigsaw puzzle.MissingPieceCount = jigsaw puzzle.MissingPieceCount - 1
</item>
</selfuseon>
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<look>You're Magoo. A simple being trapped in a test game.</look>
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
</object>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>

TM123
oh - about the pics. If I'm not mistaken, you'd need 16: one with no chips, 4 with one of each, 6 with all combinations of 2, 4 with all combinations of 3, and one with all 4.
Suggestion: each chip represents a binary bit of a 4 bit number. A = 1, B = 2, C = 4, D = 8.
Have an attribute SumInstalledChips. When they install each chip, the value would be added to the attribute. This would give you all the combinations, numbered 0 to 15. Name the pics "Pic0" to "Pic15" based on which chips are in them. (B and C = 6, all 4 = 15 etc) Then the file name would be "Pic" + SumInstalledChips

XanMag
@TM123

I got the puzzle problem to work perfectly. Thanks!

Now... the trick will be to translate all of this into my main game.

For my land mine...
This is pretty much identical to the puzzle problem that we (mostly you) just solved. The land mine will be a jigsaw puzzle and the different chips will be my puzzle pieces. Solution: I'd add an intenger attribute to my land mine equal to 6
<MissingPieceCount type="int">6</MissingPieceCount>
and with each correct placement of my 6 total parts I'd have a line like this
metal plate.MissingPieceCount = metal plate.MissingPieceCount - 1
I'd have to add a changedMissingPieceCount attribute on the land mine that tells the player the land mine is ready for use 'If' the MissingPieceCount equals 0. I'd also add a flag here that makes the 'use' of the land mine effective.

For the security cell...
Background and *spoiler* - the player must use a dryer sheet on themselves AND spray the room with water at which point they can crawl through a grate and into the cell. They can do this in any order. My grate will be my jigsaw puzzle. The dryer sheet and the spraying will be my puzzle pieces. Solution: I'd add an integer attribute to my grate equal to 2 -
<GrateRemovalCount type="int">2</GrateRemovalCount>
. When the player uses the dryer sheet on themselves and sprays the room with water I'd have a line of code at the end of that script (respectively) like this
grate.GrateRemovalCount = grate.GrateRemovalCount - 1
. I'd have to add a changedGrateRemovalCount attribute to the grate that gives the player a hint that removal of the grate is now possible 'If" the GrateRemovalCount equals 0. I'd also Unlock the exit leading from the grate room to the maximum security prison cell.

For the get away...
Background - there are six vehicles that need disabling before the player can make a safe get away.
Add an integer to the game equal to 6
<VehiclesDisabledCount type="int">6</VehiclesDisabledCount>
When each vehicle is disabled, I'd add a line of code like so:
game.VehiclesDisabledCount = VehicleDisabledCount - 1
. I would add a changedVehicleDisabledCount attribute to the game that raises a flag that the garage door (escape route) can now be raised with the correct code 'If' the VehicleDisabledCount equals 0.

Now, most of this junk none of you will find useful. I'm really just trying to walk myself through it here on the forum so I can reference it later, BUT... if any of you see any major errors in my method, please point it out before I screw stuff up and make it harder on myself!!!

Thanks a ton!!

XanMag

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums