Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Is there any support for scoring?

A topic by Garry Francis created Sep 05, 2019 Views: 274 Replies: 25
Viewing posts 1 to 12
Submitted

I'm thinking of adding scoring. I saw some references to a :score; command in an old document, as well as score_total_variable and score_variable. Is this still supported? If so, how do I use it?

Apologies if this is covered in the Adventuron Classroom reference guide, but I can't see that on my mobile phone.

You can manually implement a scoring routine. This is the relevant part from the Adventuron Classroom documentation.... 

start_at = village

locations { village : location "You are in the village.\nType JUMP to increase your score, type SCORE to see your score." ;
}

integers { // Set the default score to zero here score : integer "0" ;
}

on_command { : match "jump _" { : if (score < 20) { : increment "score" ; : print "You do something very impressive" ; } } : match "score _" { : print {( "Your score is " + score + "." )} }
}

(+1)

The formatting is off in my copy and paste, but anyone interested in seeing the code properly can go to https://adventuron.io/docs/tut/#_keeping_score 

Submitted(+1)

Great. You've also included an example of string concatenation that someone was asking about in another thread. I think there's a variable for turns, as well. I'll check it out when I get home.

: turns ;

Will automatically print the turns dialogue.

Submitted

: turns ; is no good. It says, "You have taken x turns" Note lack of closing period. This is not in the system_messages{}, so I can't fix it. This is not what I wanted anyway. I wanted to say something like "You have scored x points in y turns.", so I need turns to be a variable. I could also potentially put it in the header like in Infocom games.

In section "5.103. Turns (1)" of the old doco, it says that turns returns the number of inputs entered by the player. The example given is:

my_turns : turns ;

There is no context. What does this mean, where do I place it in the code and how do I use it?

Submitted

AAARRGGHH! This is so frustrating! The best I've come up with is:

integers {
   turns : integer_dynamic {(turns())}
}

on_command {

   : match "score _"  {
      : print {(
         "You have scored " + score + " points in " + turns + " turns."
      )}
   }
}

You can also use ticks() instead of turns(). However, on the first move, it says, "... 1 turns.", then it increases by 2 on every turn. What's going on here?
Host

You are using the old document Garry, don't refer to that, that version of adventuron 0.5.x has been largely re-written, and a lot of the placeholder functions are still there, written in the wrong format. The only document you should use is the one with the built in tutorial, and the document in the MENU button of the editor.

Anyway ... 

turns() is simply a function that returns an integer. You can only use functions like that in expressions:

e.g.

: if (turns() < 10) {

    // some code

}


You can also use turns in dynamic integers, as you described before:

integers {
   turns : integer_dynamic {(turns())}
}

But, you can also use turns in the expression form that is supported by some commands (such as print and append):

on_command {

   : match "score _"  {

      // NOTICE -- No need for a dynamic integer, just call the function directly.

          : print {(  "You have scored " + score + " points in " + turns() + " turns."       )} 

 } 

}

turns() returns the number of times that a command was submitted

ticks() returns the number of times the on_tick() method was executed.

Some commands, such as inventory, is (supposed) to stop an onward game tick. Actually there is a bug with inventory that it is not doing that. Just for the clarification.

A useful bit of code, thanks.

(I'm only seeing an increase by one, using both turns and ticks.)

Submitted

If we're playing the 'how many ways to skin a cat' game, you can also use ticks to increment a turns counter. I'm guessing this is what 8bitAG was talking about above.

I was referring to the built in ticks integer that Garry had written about. As Chris mentions, that's not quite as reliable a way of counting turns at the moment.

Submitted

Thanks for all the helpful input. It appears that turns() works in the way that Chris described. The reason I was seeing the number of turns increase by 2 was that the SCORE command itself was taking one turn. So if I typed SCORE, SCORE, SCORE, the number of turns was being reported as 1, 2, 3, but if I typed SCORE, NORTH, SCORE, NORTH, SCORE, the number of turns was being reported as 1, 3, 5.

I currently have three "meta" commands, specifically ABOUT, HELP and SCORE. These are commands that are there purely to provide information. These should not increment the number of turns. System commands like SAVE, RESTORE, LOOK and INVENTORY should do the same thing. Unfortunately, as Chris pointed out, INVENTORY is buggy in this regard.

To work around this problem, I have done this:

integers {
   score : integer "0";
   turns : integer "0";
}

on_tick {

   : increment "turns";
}

on_commands {
   : match "score _"  {
      : decrement "turns";
      : if (turns == 1) {
         : print {(
         "You have scored " + score + " points in " + turns + " turn."
      )}
      }
      : else {
         : print {(
         "You have scored " + score + " points in " + turns + " turns."
      )}
      }
   }
}

Now, when I type SCORE, NORTH, SCORE, NORTH, SCORE, the number of turns is reported as 0, 1, 2. Perfect. If I do the same thing to the system commands, they also work - even inventory! The only one that doesn't work properly is LOAD. This works fine normally, but increments the number of turns with my method.

Anyway, as an example, here's how I did inventory:

   : match "inventory _" {
      : decrement "turns";
      : inventory;
   }

I know I'm being pedantic, but can anyone see anything wrong with this approach?
Submitted(+1)

I did something a little different: I increment a variable for the use of meta-verbs, and subtract it from turns() when I display the score.

integers { faketurn : integer "0"; }

   : match "inventory _"  { : increment "faketurn"; : inventory; : done; }
   : match "save _"  { : increment "faketurn"; : save; : done; }
   : match "load _"  { : increment "faketurn"; : load; : done; }

  : match "score _"  {
      : increment "faketurn" ;
      
      : if ((turns()-faketurn) == 1) {
         : print {( "Your score is " + score + " out of a possible 10 in " + (turns()-faketurn) + " turn." )}
      }
      : else {
         : print {( "Your score is " + score + " out of a possible 10 in " + (turns()-faketurn) + " turns." )}         
      }
      : done;    }

It had never even occurred to me that someone would think that typing SCORE or INVENTORY *didn't* count as taking a turn! :-)


Host

Ticks and turns are horrible minutae details. I've added a sample piece of code into the "cookbook" section to try to bring some light onto the situation.

The system "inventory" command is now tickless as standard. 

Garry's workaround is pretty good.

To be fair, I guess Infocom games like Hitchhiker's didn't count SCORE and HELP as a turn... but they DID count INVENTORY as one.

Is there an option to set INVENTORY to tick? Or will there be. I guess if I really want it to count as a turn in future (which sometimes I do... in turn-limited situations) then I can manually code an INVENTORY response, that will make it count as a turn.

Host

Well, maybe I'll just make it count as a tick right now (don't depend on this Garry), and add a toggle to switch it off as a tick. Naturally I feel that I is a useful way of passing time when you just want to move through ticks, and wait is too many letters.

Please keep your workaround in place Garry.

Yep, I usually use I as a way of quickly passing time. 

Submitted

I go with the rule that anything 'meta' such as LOOK, EXAMINE, SCORE, HELP, INVENTORY doesn't involve a turn - but I think it varies between implementations.

Submitted

I usually use WAIT or Z as a way of passing time. I don't need it for my game, but I suppose I could add it.

Submitted

I believe WAIT is already supported, you just need to alias Z to WAIT.

Submitted

Really? How does one know what verbs are supported by default?

Submitted

I just found out by trying the command in the game (~:

Submitted

I've added wait as follows:

   : match "wait _;z _" {
      : print "Time passes...";
   }

Submitted

What I did:
integers {
   score : integer "0" ;
   lastscore : integer "0" ;
}
subroutines {

   sub_score : subroutine {
      : if ((score-lastscore)==1) {
         : print "[[The score has just gone up by 1 point.]]" ;
      }
      : else {
         : print {("[[The score has just gone up by " + (score-lastscore) + " points.]]" )}
      }
      : set_integer var = "lastscore" {(score)}
   }   
}
In code game:
   : increment "score" ;  #add var = "score"  value = "value" ;
   : gosub "sub_score" ;

Host

This is a good workaround until I finish my work on integer watcher subroutines.