Updating Scores¶
Proper score tracking is essential for accurate game state management. This includes initializing scores, updating them during gameplay, and optionally tracking score sources.
Before Scoring¶
Before recording actual scores, it's important to initialize player scores to zero. This helps establish the game session and player order.
Zero Score Importance
Always initialize players with zero scores, even if they haven't played yet. This establishes the player count and order for the session.
Score Updates¶
You can update scores for single or multiple players during gameplay.
Single Player Update¶
Multiple Player Updates¶
Score Features¶
Available Feature Types¶
The feature parameter in setScore
/sb_set_score
can be one of the following values:
Feature Constant | Value | Description |
---|---|---|
SB_FEATURE_NONE |
0 | No specific feature (default) |
SB_FEATURE_RAMP |
1 | Points from ramp shots |
SB_FEATURE_SPINNER |
2 | Points from spinner hits |
SB_FEATURE_TARGET |
3 | Points from target hits |
SB_FEATURE_SWITCH |
4 | Points from switch hits |
SB_FEATURE_JACKPOT |
5 | Regular jackpot awards |
SB_FEATURE_SUPER_JACKPOT |
6 | Super jackpot awards |
SB_FEATURE_MODE_COMPLETE |
7 | Mode completion bonuses |
SB_FEATURE_MULTIPLIER |
8 | Multiplier-based points |
SB_FEATURE_SKILL_SHOT |
9 | Skill shot awards |
SB_FEATURE_COMBO |
10 | Combo shot awards |
SB_FEATURE_MODE_START |
11 | Mode start awards |
SB_FEATURE_WIZARD |
12 | Wizard mode points |
Example Usage¶
Default Feature
If no feature is specified, SB_FEATURE_NONE
(0) is used.
Feature Selection
Choose the most specific feature type that applies to help with score analysis.
Score Types¶
Scores can be tagged with feature identifiers to track their source. This helps with analytics and gameplay insights. Next to the score, you can also add a feature identifier. These are not meant to replace targets or modes, but to add more context to a specific score increase only.
Common Score Types¶
Type | Example | Score | Code Example |
---|---|---|---|
Ramps | Right Ramp | 800 | sb_set_score(state, player, 800, SB_FEATURE_RAMP) |
Spinners | Super Spinner | 7,000 | sb_set_score(state, player, 7000, SB_FEATURE_SPINNER) |
Targets | Left Target | 1,000 | sb_set_score(state, player, 1000, SB_FEATURE_TARGET) |
Named Switches | Left Outlane | 25,000 | sb_set_score(state, player, 25000, SB_FEATURE_SWITCH) |
Jackpots | Lightcycle Jackpot | 100,000 | sb_set_score(state, player, 100000, SB_FEATURE_JACKPOT) |
Super Jackpots | Wizard Jackpot | 2,000,000 | sb_set_score(state, player, 2000000, SB_FEATURE_SUPER_JACKPOT) |
Mode Completion | Metamorphosis | 1,000,000 | sb_set_score(state, player, 1000000, SB_FEATURE_MODE_COMPLETE) |
Multiplier Bonus | 2X | 1,000 | sb_set_score(state, player, 1000, SB_FEATURE_MULTIPLIER) |
Skill Shot | Snake Charmed | 100,000 | sb_set_score(state, player, 100000, SB_FEATURE_SKILL_SHOT) |
Loop Combos | 3-Way | 2,500,000 | sb_set_score(state, player, 2500000, SB_FEATURE_COMBO) |
Mode Starts | Tiger Saw | 5,000 | sb_set_score(state, player, 5000, SB_FEATURE_MODE_START) |
Wizard Mode | Grande Finale | 150,000,000 | sb_set_score(state, player, 150000000, SB_FEATURE_WIZARD) |
Feature Usage
Using score features consistently can enable better gameplay analysis and player statistics.
Score Accuracy
Always verify that score updates are properly committed before proceeding with gameplay.
Commit Frequency
While you should commit after score changes, batch multiple updates into a single commit when possible.
Ball Updates¶
You can update the current ball number during gameplay:
Ball Numbers
- Ball numbers typically start at 1
- Update the ball number before scoring begins for that ball
- Extra balls should still increment the ball number
Combined Score and Ball Updates¶
Often you'll want to update both scores and the current ball in the same cycle:
Commit Frequency
Group related updates (like ball and score changes) into a single commit when possible.
Best Practices¶
1. Score Initialization¶
- Always start with zero scores
- Initialize all players at game start
- Commit initial scores immediately
- Verify player count is correct
2. Score Updates¶
- Update scores promptly
- Use appropriate feature tags
- Batch multiple updates when possible
- Verify score changes are committed
3. Error Handling¶
- Check for valid player numbers
- Verify score changes are reasonable
- Handle connection issues gracefully
- Log unusual score patterns