Skip to reading
Text & Sierra-Style Adventures

28. Award points once

Edition 0.86.3.4

Build a complete text or graphical parser adventure with typed commands, inventory puzzles and press-to-walk controls.

Download PDFView PDF page

Scoring is optional, but it is a useful way to make this example feel familiar. The important rule is that a completed task can award points only once, even if the player repeats commands or drops an item and picks it up again.

Source table from 28. Award points once, page 31
AchievementGuard variablePoints
First key pickupta_found_key1
Unlock cabin doorta_unlocked2
First fuse pickupta_found_fuse1
Fit fuseta_fuse_fitted3
Send warningta_signal_sent3
Total10
Code example
func award(flag: String, points: int) -> void:
    if bool(Runtime.variables.get(flag, false)):
        return
    Runtime.variables[flag] = true
    Runtime.variables["ta_score"] = int(
        Runtime.variables.get("ta_score", 0)) + points

This is the same function printed in Appendix A. It sets the guard before adding points. The HUD label uses Score: $$ta_score of 10. The controller converts the starting score to an integer so the opening display reads 0 rather than 0.0.

For a larger game, give each optional discovery its own guard. Do not use a single “puzzle complete” flag for several independent rewards unless that is the behavior you want.

Page 31 of 68Permalink
Go to page