Finishing X2: A couple final questions.

XanMag
01 Dec 2015, 04:04
This is an odd one. I have zinc powder in a mortar (container). If I type 'get powder' I get an 'I can't see that' response, but if I type 'get zinc', the following script works just fine and the zinc is added to my container. Not a big deal, but just trying to tidy it up. The object name is zinc powder and I added EDIT: an alternative name 'powder' just to test. Same results.

if (Got(container of TNT)) {
msg ("You pour the zinc powder into the container of TNT. You toss the mortar and pestle aside.")
RemoveObject (container of TNT)
AddToInventory (container of mixed chemicals)
RemoveObject (zinc powder)
}
else if (Got(empty container of salt)) {
msg ("You add the zinc powder to the empty container of salt.")
RemoveObject (empty container of salt)
AddToInventory (container of zinc powder)
RemoveObject (zinc powder)
}
else {
msg ("You don't have a container appropriate for carrying around the fine powder.")
}


Another minor clean-up... I get two room description messages after this script finishes:
SetObjectFlagOn (showers, "showers used")
SetObjectFlagOff (lever2, "water running")
firsttime {
msg ("You take a chance and exit the shower stall. You hear what sounds like singing from the other two stalls and decide it might be best to get out of here for now. You scurry ever so quietly out of the shower area, through the dining hall, and back out into the hallway.")
MoveObject (Xanadu, Long Hallway)
}
otherwise {
MoveObject (Xanadu, Showers)
}
There are no elaborate scripts that run when entering the long hallway. Just a normal room description.

And how do I stop this from running? I do not want this to run after a certain event is triggered at end game.
<script>
Commons.exovercount = Commons.exovercount + 1
if (Commons.exovercount % 10 = 0) {
n = GetRandomInt (0, ListCount (game.suntzu) - 1)
msg ("A voice booms over the loud speakers, " + StringListItem(game.suntzu, n))
}
</script>


And lastly, near the end of the game I want to remove all objects the player is carrying except for two of them. I will not now exactly which objects the player might be carrying at that time. Is there an easy way to do this without removing all objects individually?

Thanks again!

Father thyme
01 Dec 2015, 07:28
I know this sounds too simple but do you have 'powder' as a separate option in ' add other names for this object'

The Pixie
01 Dec 2015, 08:34
Not sure about the zinc/powder problem, but Father thyme's solution should fix it.

Not sure about the two room descriptions either, would have to see more of the game. Nothing obvious in the pasted code.

For stopping the script running, it is a tyurn script, right? Use DisableTurnScript.

To remove objects, use ScopeInventory to get a list of objects carried, and foreach to go through them:
foreach(obj, ScopeInventory()) {
if (not obj = firstobjecttokeep and not obj = secondobjecttokeep) {
obj.parent = somewhereelse
}
}

XanMag
01 Dec 2015, 15:42
Yes. I typed 'alias' but meant to type "alternative" name... So, yes, I do have zinc powder as the 'name' and 'powder' as an alternative/other name.

Father thyme
01 Dec 2015, 19:42
Re zinc powder You need to go to objects. Add other names for this item then add powder, zinc and zinc powder as 3 separate entries. The only combination that doesn't work with this is powder zinc but you could add that as powdered zinc if you like. I added them all temporarily to my game and they all appeared in the Martian desert.( which is where my player is at present.)

XanMag
02 Dec 2015, 02:33
I'm almost too embarrassed to admit this... but...

Zinc powder "problem" was solved. It was as simple, and idiotic as accidentally leaving the mortar (the container) containing the zinc powder box ticked for 'hide children until object is looked at'. D'OH!

Thanks for the help though.