I am having trouble with what I want to do in I7. Here is what I want to happen - there are 4 trophies and 4 pedestals. There are certain actions that need to take place in order for you to be able to place a trophy on a pedestal. (Like a player must look inside the briefcase and read the papers, before they can place a trophy on pedestal #2.
I have tried a LOT of different things I have found by searching this site, the manual, and googling. Here is my latest try for code dealing with this issue (i just gave one of the trophy’s code for an example):
val1 is a number variable. val1 is 0.
val2 is a number variable. val2 is 0.
val3 is a number variable. val3 is 0.
val4 is a number variable. val4 is 0.
Before examining the papers:
increase val1 by 1;
continue the action.
Before searching the briefcase:
increase val1 by 1;
continue the action.
Instead of putting [Delaney's trophy] on [1st place pedestal]:
if val1 is 0:
say "You do not have enough information to make this decision.";
stop the action instead;
if val1 is 1:
say "You have an idea who's trophy goes here, but you are not sure.";
stop the action instead;
if val1 is 2:
say "You are almost sure, but you still need more information.";
stop the action instead;
if val1 is 3:
say "You still need a bit more information.";
stop the action instead;
if val1 is 4:
say "You place the trophy on the pillar.";
continue the action.
I’m sure you can see the problem I run into - it runs that way for ALL “putting on”, not just for the 1st pedestal. If I take away the brackets, the code throws errors. How do I state what I want to do?
seeing your response with “first” made me try something - I had the name as “1st place pedestal”. I’m sure you all already know, but I had no idea you couldn’t use numbers in names. Sorry, for wasting your time and thank you so much for the help! I changed the name and it seems to work fine now.
A separate point, but by incrementing Val1, etc. in a before rule (which kicks in before any check rules, etc.), I think you basically give credit to the player for doing the various things even if something else blocks his ability actually to do the thing that gives him the information. Thus, for example, if the briefcase happens to be in the possession of an NPC and the player tries to search it, I think (I could be wrong on this) the standard rules would prevent the player from successfully searching it; however, by the time that rule kicks in you would have already given the player credit for the knowledge by bumping up Val1.
Also, it looks like your code would allow the player to repeat any one action and get credit for it each time (i.e., he could search the briefcase 4 times and then be able to place the trophy on the pedestal without ever having done the other things you want him to do to get info).
Just pointing this out – that may be what you want or you may have addressed these issues in a portion of the code that is not reproduced here.
Thanks for your insight! I had thought of the infinite increase of val1 by reading the papers as many times as you wish, and since I got the other problem worked out I changed it to this(creating another number variable called “papercount”):
Before examining the papers:
if papercount is 0:
increase val1 by 1;
increase papercount by 1;
continue the action;
otherwise if papercount is 1:
continue the action.
I had not thought of something preventing the searching of the suitcase however… I will change it to after. Thank you again!
Actually I’m still having a bit of trouble, because I do not want the player to be able to set anything else on the pedestals, except trophies… I tried doing this with (a ugly looking bit of code):
Instead of putting something other than Delaney's trophy or Agatha's trophy or Dr John's trophy or Nancy's trophy on the first place pedestal:
say "You need to save room on the pedestal for the correct trophy.";
stop the action.
I7 doesn’t understand this though, and I think maybe I need to make trophy a kind? - and disallow that?
Just a little comment, but I think something this would be easiest the problem of multiple examinations of the papers, and also if the player was prevented from examining the papers (like if he was in a dark room) then it wouldn’t be counted.
After examining the papers for the first time:
increase val1 by 1;
continue the action.
Instead of putting [Delaney's trophy] on [1st place pedestal]:
the parts in square brackets are being commented out. Square brackets in quotation marks are text substitutions. but everywhere else they’re comments, which the source code doesn’t read! So Inform is reading that line as:
Instead of putting [...] on [...]
or just “Instead of putting on,” and every single “putting on” action is getting blocked.
It sounds like there are two separate issues embodied in this. If the player tries to put something other than a trophy on a pedestal, you porbably want to tell him right away that the pedestals are for trophies. On the other hand, if he tries to put the wrong trophy on a pedestal, you probably want to block it, but you don’t want to tell him that it’s the wrong one unless he has gathered the necessary knowledge.
I think both of these can be facilitated by creating a trophy “kind,” and declaring each of the four trophies to be a trophy. Then, the first case could be handled by a separate “instead” rule which kicks in only when a player tries to put something other than a trophy on a given pedestal. The second case could be handled within the existing “instead” rule, modified so that it applies when a player tries to put any trophy on Pedestal 1. When you get to the end of that rules (i.e., the part which kicks in where Val1 is 4), you add an additional test to see if the trophy is the right one, and either allow it or block (with an appropriate message) depending on the outcome of that test.
Of course, this still requires separate rules for each pedestal. My guess is that you might be able to figure out a way to do it all within a single rule, possibly using a table to keep track of which is the correct trophy for each pedestal and which counter variable keeps track of the player’s state of knowledge applicable to each pedestal.