Some Questions About "Score"

chellkafka
First of all, I tagged the score-feature in the game-tab, but I don't find any indication that it is active, or how to use it. So I really don't have any idea what to do with it and I thought that it would be useful to make 2 different endings depending on what score you have, but as I said I just don't have any clues. Any ideas why?

Which leads me to my next question, can the score-feature be used in that way? As in tracking the players action so that there could be different endings depending on those actions? And how?

I want to make a game about obedience and disobedience. The player progresses through a series of rooms and sometimes the player needs to do something to progress. Sometimes it requires some steps to progress. Sometimes it's essential to do the steps in the right order, but sometimes not. And though it is not essential, I still want that the player only scores when he does it in the "right" order. Is that possible? And if yes, how?

jaynabonne
If you turn on panes (Features/Interface/Layout), you will see the score in the Status area. Otherwise, you'll have to display it somehow yourself.

How would you like it to be made available to the player? You could, for example, add a "score" command that shows the current score.

chellkafka
Sorry, you misunderstood me. I don't see any attributes or anything alike when editing the game. True, it now shows the player, but that's not important to me. I just don't know what to edit. Or where to look or I just don't know.

jaynabonne
I see (I think). The score is an attribute on the "game" object. In code view, it shows up like this:

   <Score type="int">0</Score>

In the editor, you should be able to see it in the "attributes" pane of the game object.

I hope that is closer to what you meant. :)

chellkafka
Nope. Nothing in Attributes.
In code view, the only thing I found, was this:

<showscore />


I'm really not trying to be a pain in the ass. But whether I am able to do this or not, is a crucial design choice, I can't really move on with the game until I know. So, help? Please?

chellkafka
If it helps, I was looking over the Score Library on the questwiki. And the first steps, says I should call a function called InitScore, but it wasn't found. I even checked the library elements, it wasn't there. I found InitStatusAttributes and funnily enough IncreaseScore and DecreaseScore. Don't know if that helps.

jaynabonne
To be honest, it all comes down to what you want to do. If you're not going to use the built-in score stuff to show the score in the side pane, then you can just create your own "score" variable (e.g. stick it in "game" or on "player") and then update it however you like. And then use it how you like as well. It's really just a variable, and you have total control over that.

chellkafka
No, no, I do want to use the built-in score stuff, I honestly just don't know how to. I figured out that calling the IncreaseScore-function with a parameter of 1 increases the score by 1 and decreasescore also works. I was just confused because I didn't see anything of the score in the editor, but now I see it is there.
So I know how to increase and decrease a score, perfect. Now, how can I make sure that the score is only getting increased when the player does the required things in the right order. Like, player has to do A, B and C to progress, but the steps are interchangeable, so the player could do B, A and C or C first and then A, B or everything reversed, C, B, A. But in order to score the player needs to do it in the order A, B, C. Get it?

A concrete example:

At the beginning, the player is required to look around in order to spot the door and go through the door in order to progress into the next room. So if the player types in "look around" and then "go through door" then the score should increase by 1, but only then. If the player types in something different or "go through door" first and then "look around" or "look around" first and then a second time, the score should decrease by 1.
I tried it by using the start-script and running get input. then if player is in room 1 then if expression result = look around etc.
But I realised that this setup wouldn't get the right order of the commands. Does anybody have an idea?

And is there like a script or a function which I place at the end and the script or the function reads the score of the player and whether if the score is negative, 0 or positive a different ending happens?

Sorry, if I'm not being clear, I'm not trying to.

jaynabonne
As far as getting input, you can easily create custom commands (e.g. explicitly require things like "look around" or "go through door"). Then you those will be called only when the player types in what you want.

(A personal note... I don't know your exposure to text adventures, so I'll err on the side of too much and state: be sure if you're going to mess with conventions, that you give the player plenty of clues about it. Something like being penalized for looking at the room twice could get people a bit irritated. Also using "look around" as opposed to the standard "look" could either make it hard for people to work out or inspire undesired levels of frustration. I'm not trying to get you to change your design. I'm just noting a couple of things in case you were unaware of the design ramifications. You can make it do what you like! )

I think to track a sequence, you could use a state variable of some kind that advances when each step is performed and reset when one is done out of order. For example, start it out at 0. Then:

for look around: if (state = 0) then { state = 1 } else { score = score - 1; state = 0 }
for go through door: if (state = 1) then { score = score + 1 } else {score = score - 1; state = 0 }

If that makes sense. :) Basically, if they do something out of sequence, they're penalized and the state is reset. Else it advances to the reward.

As far as end of game, you could have a final room which checks the score on entry and does appropriate things depending.

chellkafka
Ok, first of all, thanks for staying with me after all these replies and trying to help me out, I really appreciate it.
And thanks for the advise, but positive and negative score isn't really a reward or penalty kind of thing. I want to use it as a way to determine what ending I want to give the player. What I try to do with the game is, to convey a feeling of what I think that obedience and disobedience is about, just through gameplay. Not by narration (like really telling the player), just by interacting with the rules I laid out. And the score, I would display it through narration. So if you obey to the current objective of the game and would therefore score a point, I would have displayed something like "Well done. Here, a cookie." or more likely something else (I really don't want to imply that obeying to something makes you dumb or whatever.) But scoring the point, doesn't give you any advantage, it doesn't give you any progress, it just is a kind of conditioning, an attempt to keep you from disobeying and disguising the fact that there are other ways. I know that it is very paradox, and there is even a term for that called ludonarrative dissonance( the story says you did A, but the game mechanics say, you did not A), but it is exactly the kind of feeling I want the player to have. Not knowing what exactly is "right" or "wrong", so the player has to decide for himself what is "right" and "wrong".
And I want to include instructions for the game, saying that only typing in look around, etc. will work. Which is like laying out a controller with buttons. When you have a controller you can see and feel that these are the only buttons, but with text adventures you really have to point out that these are the only buttons. so i got that covered too.
and sorry for the long text, but I felt there needed to be a justification for turning down a good advice.

now back to business:
I'm really bad at coding, I mean, really bad. could you tell me where I have to copy those code samples you posted? Because it pretty much sounds like the thing I want.

jaynabonne
Thanks for the explanation. That helps. :) And now for your reward, here's some code: (lol)

    <command name="LookAroundCommand">
<pattern>look around</pattern>
<script>
msg("Some text describing the room.")
if (game.state = 0) {
game.state = 1
} else {
game.state = 0
DecreaseScore(1)
}
</script>
</command>
<command name="GoThroughDoorCommand">
<pattern>go through door</pattern>
<script>
game.pov.parent = NextRoom
if (game.state = 1) {
IncreaseScore(1)
msg("Well done! Have a cookie!")
} else {
game.state = 0
DecreaseScore(1)
}
</script>
</command>


If you put these commands in the room, then they will only exist when the player is in that room. I put in some placeholders for the actual "look" and "go" functionality (the commands need to respond the way the player expects). What you want that to be, you can work out.

chellkafka
Thanks a lot for the code, it seems to work, but I encountered this problem:

Error running script: Error compiling expression 'game.state = 1': CompareElement: Operation 'Equal' is not defined for types 'Object' and 'Int32'

So, here's how I applied your suggestions:

if (game.pov.parent = look around room) {
if (game.state = 1) {
IncreaseScore (1)
msg ("Well done! Have a cookie!")
}
else {
game.state = 0
DecreaseScore (1)
}
if (ListContains(ScopeVisible(), lookaroundroomdoorobject)) {
MoveObject (player, test look around room)
}
else {
if (RandomChance(1)) {
MoveObject (player, test look around room)
}
else {
msg ("You bumped into something.")
}
}
}
else if (game.pov.parent = test look around room) {
if (ListContains(ScopeVisible(), testlookaroundroomdoorobject)) {
MoveObject (player, pull room)
}
else {
if (RandomChance(1)) {
MoveObject (player, pull room)
}
else {
msg ("You bumped into something.")
}
}
}


and for look around:

if (game.pov.parent = look around room) {
firsttime {
MakeExitVisible (lookaroundroomdoor)
MakeObjectVisible (lookaroundroomdoorobject)
msg ("You see a door.")
if (game.state = 0) {
game.state = 1
}
else {
game.state = 0
DecreaseScore (1)
}
}
otherwise {
firsttime {
MakeObjectVisible (piece of paper)
msg ("You notice a piece of paper.")
}
otherwise {
}
}
}
else if (game.pov.parent = pull room) {
firsttime {
msg ("You see the lever.")
}
}
else if (game.pov.parent = test look around room) {
MakeExitVisible (testlookaroundroomdoor)
MakeObjectVisible (testlookaroundroomdoorobject)
msg ("You see a door.")
}
else {
msg ("")
}


I included the whole code of the commands, maybe the problem lies elsewhere.
anything wrong with that?

jaynabonne
Sorry! I forgot one key part. (Ah yes. The perils of getting older.)

You must also define a "state" attribute on the "game" object, type "integer" and with an initial value of 0. The scripts depend on it already existing.

chellkafka
Yes, great! Thank you!
There is one thing though: is there a way for the state changes to add up? because, it does only increase the score if you do the commands in the right order, but it does not take in account what happened before. Also, the score should only be decreased if you advanced in a different way, not everytime you do something different.
I guess, I could use different values for different situations, but I guess the adding up would be much more efficient as I won't be able to think of every situation.

jaynabonne
You can change the state and score however you like. :) What I showed is just one way to do it. You would need to change it to match the actual behavior you wish. The scripting is fairly trivial (ok, ok, I know) - the hard part is working out how you want it to act. If you could clearly define the behavior, I might be able to help with getting it to work, but it would need to be really spelled out.

chellkafka
Ok, I want that instead of setting the game state to 1, 1 gets added. So if you make a "mistake", it can't be undone.

for example:

in the first room, you have to look around first and then go through door. if you look around then 1 should get added to "state" no matter what. if the game. state is 1, go through door increases the score, but if it is anything but 1, 2 should get added to game.state. So if you don't play along right from the beginning, you don't score.

Is that clear? The adding is the crucial part. That a certain state variable gets set to a certain state variable, but instead a certain amount is added to a certain state variable.

jaynabonne
Almost clear... what happens if you look and then look again and then look again? Is the state 3 at that point?

I think the state thing might need to be local as well. If the player makes a misstep early on (e.g. looks twice before going out the door), then they would never be able to "catch up" and begin scoring again, as their initial double take would put them forever out of sync. If that makes sense... (I'm speculating on what happens after "go through door".)

jaynabonne
Actually, it might be helpful to take a step back, and take a broader view. We've gotten down in the weeds with the whole state thing, and it might be clouding the discussion a bit. Let's forget the implementation for a moment and look at the requirements.

Let's say you have an ideal sequence of input: A B C D E F G H I...

At each step, the player is expected to do "the right thing". The score tracks how well they have been following along, with more negative numbers being "less obedient" and more positive numbers being "more obedient". It's not so much positive or negative as much as a position along a scale.

Initially, they need to do task A. If they do task A, they get shifted toward the "obedient" side. If they do something else, they get shifted toward the "less obedient" side. (If they repeatedly don't do A, do they shift further and further to the "not"? Can they redeem themselves?)

Once they have completed task A, then they move onto task B. Note that eventually they will hit task A, so they will at least get a point in the "more" direction. While expecting task B, if they do anything else, a point is taken away (shifted left on the scale). When they execute task B, they get a point and move on to C as the expectation.

In the end, you have a "score" which represents the number of correct steps minus the number of incorrect ones.

If this is what you want, then we need to be clear of one thing: the player should not end up in a state where they are no longer able to take the right step. For example, if the next expected step is "look around" and they then type "go through door" such that they are no longer able to look around, then the scoring gets stuck - they end up not being able to advance because they are no long able to perform the next expected step. There need to be constraints such that they eventually will continue along the desired path.. So as long as that is understood (and what I've described is what you want), then I can whip something up.

chellkafka

Almost clear... what happens if you look and then look again and then look again? Is the state 3 at that point?



Exactly! Is that possible? And how?

I think the state thing might need to be local as well. If the player makes a misstep early on (e.g. looks twice before going out the door), then they would never be able to "catch up" and begin scoring again, as their initial double take would put them forever out of sync. If that makes sense... (I'm speculating on what happens after "go through door".)



If the player progresses(moves into next room) state will be reset to 0. A score increase or decrease should happen when the player progresses. So you can make so much "missteps" as you like, you'll just lose 1 point. so when player types go through door (and meets all the requirements, you have to have spotted the door and unlocked it) there would be a if script implemented which you suggested would check the state variable. If the state variable is the amount that only could be achieved if the steps where done in right order, you'll get a point. If the state variable is something else, you'll lose one point.
Was that what you meant?

chellkafka
It's not about how much obedient or disobedient you are, it's whether you are or not. If you are obedient you get a point. If not you'll lose a point. And that's just concerning one room. So this would happen in every room. You could have 0 points at the end of the game because you obeyed in one room, but disobeyed in another and so on and on.

chellkafka

If this is what you want, then we need to be clear of one thing: the player should not end up in a state where they are no longer able to take the right step. For example, if the next expected step is "look around" and they then type "go through door" such that they are no longer able to look around, then the scoring gets stuck - they end up not being able to advance because they are no long able to perform the next expected step. There need to be constraints such that they eventually will continue along the desired path.. So as long as that is understood (and what I've described is what you want), then I can whip something up.



Yes, yes, i never intented to disable any commands or ways of interaction. Scoring isn't tied to advancing through the game. It just should show how you advanced.
So I would have designed the rooms that there would be obedient and disobedient solutions to advance.

EDIT: So, what I need is a way of keeping track how the player advanced.

jaynabonne
I think we're getting closer... :) So if, within one room, you don't do the right thing 3 times and then you *do* do the right thing such that you progress, your score would be 0? (A -1 score for all the missteps and then +1 for getting it right.)

Or is score computed per room? (If I make the right steps in the current room, I get a +1 for this room, else I get -1 when I leave.) And then your score would be the sum of the room scores?

jaynabonne
This might help as well... (rubs hands together). Use cases... Assuming an ideal sequence of A B C D, what would your score be for the following:

1) A B C D

2) A A B C D

3) B A B C D

4) A B D C D

5) A B D C C D

jaynabonne
Actually, one more:

6) A A A B B B C C C D

chellkafka

Or is score computed per room? (If I make the right steps in the current room, I get a +1 for this room, else I get -1 when I leave.) And then your score would be the sum of the room scores?



Exactly!

Use cases... Assuming an ideal sequence of A B C D, what would your score be for the following:

1) A B C D

2) A A B C D

3) B A B C D

4) A B D C D

5) A B D C C D

6)A A A B B B C C C D



If 1) was ideal, then 1) gets you a point. All the others lose you a point. If they are either-or cases meant for one room.

Maybe an example will clear things up:

I have a room, where a "guide" tells you: "There is a lever. Please look around first and then pull it. Then go through the door." Now, in the previous rooms you learned that looking around makes things visible and gives you new information. But the information was already given and the objects are already clearly visible. So the obedient way of advancing would be to look around, then to pull the lever and to go through the door.
But the player could also just pull the lever and go through the door. The player also just could go through the door as the lever doesn't open it.
So there are three possible solutions, but only one will get you a point. The other two will lose you a point.

chellkafka
Or there could be a room where the guide tells you to push a button to open the door. But if you look around, you'll discover dynamit and matches and you can blow the door up.
The first case gets you a point, and the second loses you a point, but you still advance.

jaynabonne
Ok, I think I got it. Let me ponder it a bit and I'll get back to you. I think the trick was the per-room part. Basically, did you get out of the room the right way (more or less).

Given the propensity for people to look around, you might want to make the points more "chunky" - that is, key whether you passed the room or not on something higher level like did you push the button or use the dynamite to get out, as opposed to how many times you looked around. It also seems that if you look around and find the dynamite and matches but then actually push the button to leave, that you've done what you were told - unless the guide explicitly tells you *not* to look around.

chellkafka
Great, thank you.
I know what you mean and you're right. In that case I would do it like that. But sometimes I want it to be very picky. Like in school for example, mathematic. Sometimes the teacher just wanted you to have the right result, didn't matter how you got it. But sometimes the teacher demanded that you do it the way he just taught you, didn't matter if you wanted to or you had a better solution or whatever. I at least had such teachers. And that's the feeling I want the player to have.

jaynabonne
So what I think makes sense is that since the score is per-room and applies to your time in that room (and is pass/fail sort of thing), you would want to gather a score (either +1 or -1) during your time in the room and then apply it when the player exits. That saves (at least) having to worry about whether the score has already been added or not.

The basic idea is to set things up when the player enters the room and then update the score when the player leaves:


<enter type="script">
this.state = 0
this.score = 1
</enter>
<onexit type="script">
IncreaseScore(this.score)
</onexit>
<command name="LookAroundCommand">
<pattern>look around</pattern>
<script>
room = pov.parent
msg("Some text describing the room.")
if (room.state = 0) {
// Ok so far. Go to next state.
game.state = 1
} else {
// Fail!
room.score = -1
// To prevent a good message on the look/look case.
room.state = -1
}
</script>
</command>
<command name="GoThroughDoorCommand">
<pattern>go through door</pattern>
<script>
room = pov.parent
if (room.state = 1) {
// They made it!
msg("Well done! Have a cookie!")
} else {
// Fail!
room.score = -1
}
// Go to next room. This will update the score on exit.
game.pov.parent = NextRoom
</script>
</command>


You start the score for the room out on a positive note (assume success). If they misstep anywhere along the way, set the score to -1. Then when they leave the room, the master score is updated from the local one. I put the state on the room as well, since it was local. You could keep it on the game if you prefer.

I *think* that gives you what you want. :)

chellkafka
Man, I can't convey to you how much you blow my mind by the fact that you sat down to write a code, like, wow, thank you.

So, as I said, me really bad at coding.
So can I copy that and just paste it somewhere in code (where exactly?) because I'm not sure if those remarks like "//Ok so far. go to next state." are part of the code and if they are I really have to sit down to coding again 'cause I know nothing.

jaynabonne
The parts starting with "//" are just comments, to try to explain what I was doing. You can delete them if it all makes sense (or not!). You could just drop that code into your room definition. That was my intent anyway (sorry I didn't state that). The enter/exit/commands will all be specific to the room. You can then duplicate that for other rooms and adjust it for the behavior there.

You could, in theory, create a room base type. Then the enter and exit functions would be common to all rooms that you inherit the base type from. The complication is that if you override the enter or exit functions in a room, you'll lose the default behavior. So let's leave it as that for now.

See if that works for the first room. I hope other rooms will be straightforward enough. I suppose we'll see. :)

chellkafka
ok, so I created functions for look around and go through door. can I take the parts from your code and just put them there?
could you maybe explain the underlying logic of your code because it seems like you thought I didn't code anything, but I did and I really want to apply your mechanics to my code.

jaynabonne
Going back and looking at your code, I see one problem, which is that you're using a separate room for each step, which is something that didn't come out in our discussion before (since we were talking high level). I was using "room" in the sense of "the location where the player believes himself to be" as opposed to an internal construct.

So when you had talked about looking around and then going through a door - and you had said you get a point per room - I had assumed that you would get one point when going through the door - you've left the room. However, now I'm back to being confused again, since I'm not sure if our definition of "room" is the same thing, since you *internally* change rooms after looking around, which I neither expected nor propagated in the code I gave you.

I guess I'm back to square two or three. :) For the sequence "look around" and "go through door", once you're gone through the door, do you have one point or two? Is "room" what the player considers a room or what you are internally considering a room?

If you do mean to have a point added only when the player leaves the visible room through the door, then I think the way you have structured your code is going to make life hard for you, since you can't use the normal room events. The code I gave you assumes the player remains in the room until they leave. You could probably salvage it by putting the "exit" code only on the "go through door" room exit code. That means that some of your internal rooms would score point and some wouldn't. It would work, and it would preserve your existing structure, but it might be confusing a month from now. You'd also need to not use the per-room state variables as I used them, since the player doesn't remain in the same internal room. In other words, move the state back to the game object by replacing "this.*" with "game.*".

As far as the commands go, you could probably just replace them with your "get input" checks.

Assuming I still understand what you want, if you post your full game again (with your attempt to integrate), I can try to get it to work.

chellkafka
Oh, no, the names of the rooms are misleading. The names are that way to capture the tutorial feel I want to do.
So the look around room is called that way because I try to teach the player the basics of looking around in that room like a lot of games like Portal or Super Mario teach the player in their first few levels while their in game.
So they are all separate rooms and they function as rooms, they just have those names cause they also function as an in-game tutorial.
I hope that cleared things up.

jaynabonne
That makes sense, and I figured as much. My question is as before, though: at what point do you update the score? Do you get a point when leaving the "look around" room and then again when you leave the "go through door" room, or is it aligned more with the player's point of view, where looking around is still in the same "room", and you only get the point when you go through the door?

chellkafka
Well, the score should get updated when leaving the room, so when the player walks through the door. the exits are just one way so once the player left the room, he can't go back. and if he followed the instructions, he gets +1, if not -1.
Did that answer your question?

jaynabonne
Yep. Actually, reviewing the code, I realized that I totally and needlessly confused myself earlier. So please ignore anything (before this) that I've written today...

I think at this point I'm supposed to be telling you how to integrate my code with yours, but I'm not sure what yours is at the moment. I have the initial file you posted. I'm also not sure what of the file you want to keep vs. change to adapt to what we have proposed. For example, in the "enter" script for the "look around room", you have a "get input" call, which I believe is unneeded. And I don't know why you have a script on the door that also does "get input". The code also seems to have more than what you related before - for example, when executing "go through door", there is a bunch of logic that I don't understand, so I don't know how to figure out where to put in the scoring code. I *think* a bunch of that code can go away, but I don't know exactly what you're trying to accomplish with it.

So how would you like me to proceed? If you want me to integrate with your latest code, then attach it here again. Otherwise, the basic points to what I posted are:
1) Code to reset the state and room score on entry to the room
2) Code to apply the room score to the overall score when the player leaves the room
3) Code to set the room score to -1 if the player ever missteps.
4) *Per-room* commands.

The key thing to 4, which you might want to really consider to simplify your logic, is that you can have commands that are room-specific. Just place them in the desired room. Instead of having a global "look around" command which then has to check which room the player is in, you just have a "look around" command in each room, which handles the input for that room.

chellkafka
Yeah, so the get input scripts you mentioned were solutions that I came up with to problems that I don't know how to solve otherwise. So the input call at the enter script of the room was my solution of disabling a timer whenever the player did something within the game, so not just typing in something random like plkjhugfgh, but typing in something that means to the game. i don't know if there's a better solution, but that's the one I came up with.
the other I really have no idea of how it got there, just saw it the first time when i switched to code view. most of the time i work in editor mode, only occasionaly working in code view and in editor mode I couldn't find anything, just after switching to code view. Is that strange?

I would totally change the complete code, but I want the ideas to be maintained.

Ok, so I'm gonna try it do it by myself 'cause I think this is gonna be really valuable coding lessons and I kinda feel bad for letting you write the code just because I can't do it myself and eventually even dumping them just because I couldn't communicate my ideas clearly, but I really would need you to guide me through it.

So
1) Code to reset the state and room score on entry to the room


So should I create state and score variables for every room to do that? Or is it done once I did it with EDITevery EDIT ENDroom? (I myself believe not, but I wouldn't be surprised if that was the case) Or are they already in the default room? Is it necessary to use "this.score" and "this.state" or is that just a name and I could rename it whatever I feel like? Which is crucial I guess for point 2, as well.

2) Code to apply the room score to the overall score when the player leaves the room



So I got that part, but what confuses me though, is that you used game. state instead of room. state that one time.

if (room.state = 0) {
// Ok so far. Go to next state.
game.state = 1
} else {
// Fail!
room.score = -1
// To prevent a good message on the look/look case.
room.state = -1


Was that intended or a mistake? Cause I thought that it was all about the room.state.
Also this part

<onexit type="script">
IncreaseScore(this.score)
</onexit>


is problematic, if I understood it correctly, because it will only increase the score by 1 if I wouldn't add any commands to the already existing ones. But I intented to do. I know, I didn't make that clear in our discussion, sorry, but I want a tracking system that could be used for as many commands as you like. Is that too much to ask? I really couldn't tell.

And finally

4) *Per-room* commands



can that be done in editor mode? cause I couldn't figure it out yet and for now I really would want to stay with the editor mode at least until I have some reasonable coding skills.

jaynabonne

So should I create state and score variables for every room to do that? Or is it done once I did it with EDITevery EDIT ENDroom? (I myself believe not, but I wouldn't be surprised if that was the case) Or are they already in the default room? Is it necessary to use "this.score" and "this.state" or is that just a name and I could rename it whatever I feel like?



Attributes get created when you assign to them, so you don't need to pre-create them in the rooms. They will come into existence when you first assign the 0 to them. And you don't have to put them in the room - you could just as easily put them in the game (just use game.state instead of this.state). They could even be on the player object if you like. :) It's up to your design, really. They just need to be attached to some object so they persist.

You're right: the use of game.state was a bug. I thought I had quickly corrected it in the text, but perhaps I missed another.

is problematic, if I understood it correctly, because it will only increase the score by 1 if I wouldn't add any commands to the already existing ones.



I'm not sure what you mean there, to be honest, so I'll try to answer what I think you might be asking. The way the code is set up, it assumes the player will make all the right moves, and so sets the room score to 1 initially. Then if they stray from the path, it sets -1. You could do it the other way as well, if you wish (assume they go wrong by init'ing to -1 and then only set it to 1 if they succeed). You should be able to add all the commands you like. You would just need "state" to be the right value at each step of the sequence. If it is, just increment it (or set the next value); if it's not, the room score becomes -1, and maybe set state to some value like -1, so that things don't accidentally trigger. (Also, I'm not sure if it's confusing, but IncreaseScore just means "add the passed value to score". So if you pass -1, it will add -1 to the score or actually decrement the score.)

can that be done in editor mode?


Actually, I just looked, and your GoThroughDoorCommand and LookAroundCommand are already in "look around room", which means they wouldn't have been active in the "pull room" anyway. (You can tell because they show up as children of the room.) To add a room command, just right-click on the desired room and choose Add Command. Or if the command already exists elsewhere, you can simply drag it into the room you wish, as you can with any other object.

I'm glad to assist you with your coding, so let me know how it's going or if you hit any snags. (Oh, and Happy Easter, if you're so inclined!)

chellkafka
Alright, thanks. Let's see how it will turn out. Will definitely let you know.
And Happy Easter to you as well, thanks!

chellkafka
Ok, it works. I had to create room attributes though and settle on one name, but it works exactly how I want it to. Thanks a lot. I have what I want now AND I learned useful things bout coding. Pretty awesome, thanks.
I even figured out how to create different endings based on the score.
So, thanks a lot, man. For all the help, the patience and yeah, just thanks.

jaynabonne
No problem. Glad I could help! And congrats on your growing scripting skills. :) Given what I saw of what you had done, I figured you'd make short work of it.

chellkafka
ok, i'm back again.
for some reason i can't find, i can't make your score system work again.
could you maybe look over the attached file?
if you enter "skip" when you play the game, it will skip to the second room and you have 1 point. now, if you enter "look around" and "go through door" you should get another point and if not you should lose a point. But the score doesn't change. don't know why.

jaynabonne
I believe the problem is here:

      if (ListContains(ScopeVisible(), testlookaroundroomdoorobject)) {
MoveObject (player, pull room)
}
else {
if (RandomChance(1)) {
MoveObject (player, pull room)
}
else {
msg ("You bumped into something.")
}
}
if (testlookaroundroom.state = 1) {
testlookaroundroom.score = 1
}
else {
testlookaroundroom.score = -1
}

You add the score on when you exit the room. However, you move the player out of the room (and execute OnExit) before you set the score to 1. So it adds 0. I think if you move the score adjust logic above the rest, it will work.

chellkafka
ok, yes, that makes sense. it works now, thank you. it has downsides to work differently than the standard layout i guess.
but i wonder, why does it work with the first room? i thought i did the same thing with the second one?

jaynabonne
I think because you default the room score to 1 in the first room but 0 in the other. That might be a simpler way to go - set the score to 1 initially and then only set it to -1 if they have a misstep (but still before they leave the room!).

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

Support

Forums