basic question on checking inventory

Apologies if this is too basic - I've been using the GUI for a while and am only just starting to explore the code view.
I have a student writing a game. She is doing a mystery and wanted to implement a simple clue system, in which doing certain things (looking at objects, unlocking certain rooms, etc.) would put a non-droppable clue object into the player inventory.

The idea is that the player can use a "deduce" command at any time to check to see if they have a sufficient number of clues, in which case the script will remove the clues to an offstage room and put a "solution" object into the player inventory. Possessing this object will allow the player to enter the final room and see the endgame.

The trouble is, I am trying to use Code View to simplify my IF-THEN-ELSE commands. I need to be able to check if a player has Clue1 AND Clue2 AND Clue3 (they get the solution), ELSE IF does the player NOT have Clue1 AND NOT have Clue 2 AND NOT have Clue3 (they get a "You are clueless" message), ELSE the player must have some but not all of the clues and they get a gentle prompt to keep exploring.

I have tried and tried but I cannot get the code to work. My "and"s and "or"s seem to be in the wrong place. I found the online web tutorials about using ANDs in IF statements, but those pages do not refer to objects. I tried applying what those pages said to the code that showed up when I clicked on Code View, but it didn't seem to work . . .

If you need to see my code, let me know and I can post a screenshot.

Many thanks!

-Hubble


If you need to see my code, let me know and I can post a screenshot.

If you're asking what's wrong with your code, that's very hard to answer without seeing the code.

A screenshot works, but it would probably be easier to just paste the code. If you put three backticks (```) on a line by themself above and below it, it will stop the forum from mangling your code. This is one of the bigger advantages of code view; that you can just copy and paste your code to the forum for other people to see.

That said, if you're looking to test if the player has three objects, I would expect it to look something like:

if (Got (Clue1) and Got (Clue2) and Got (Clue3)) {
  // code goes here for if the player has all 3 objects
}
else if (Got (Clue1) or Got (Clue2) or Got (Clue3)) {
  // code goes here for if the player has some of them but not all
}
else {
  // code goes here for if the player doesn't have any clues
}

Ah, apologies for being dense. After getting some errors, I was wondering if my use of spaces in the object names was causing a problem. My changes to test that out were fouling things up. It's now working perfectly. Many thanks.


Log in to post a reply.

Support

Forums