scripting:samples:hiscoretable
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
scripting:samples:hiscoretable [2023/04/17 12:22] – created mit | scripting:samples:hiscoretable [2023/04/23 18:40] (current) – mit | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | $kScoreboardName = " | + | This script demonstrates use of the sysHiscores functions. |
+ | A & | ||
- | function HiscoreDisplay() | + | The script uses a module variable ' |
+ | |||
+ | The example shows a board that stores times and the board is ordered so the lowest time is at the top of the score table. | ||
+ | |||
+ | < | ||
+ | $kScoreboardName = " | ||
+ | |||
+ | function HiscoreDisplay( | ||
{ | { | ||
osdcreate( OSDWINDOW," | osdcreate( OSDWINDOW," | ||
Line 13: | Line 21: | ||
$colName = 180 | $colName = 180 | ||
$colScore = 400 | $colScore = 400 | ||
- | |||
- | sysHiscoreTable( $kScoreboardName, | ||
while( $loop < 10 ) | while( $loop < 10 ) | ||
{ | { | ||
- | $score = sysHiscoreGetScore( $kScoreboardName, $loop ) | + | $score = sysHiscoreGetScore( $boardName, $loop ) |
if ( $score > 0 ) | if ( $score > 0 ) | ||
{ | { | ||
$rank = $loop + 1 | $rank = $loop + 1 | ||
osdadd( TEXT, $colCount, $liney, 0, 0, "", | osdadd( TEXT, $colCount, $liney, 0, 0, "", | ||
- | $name = sysHiscoreGetName( $kScoreboardName, $loop ) | + | $name = sysHiscoreGetName( $boardName, $loop ) |
osdadd( TEXT, $colName, $liney, 0, 0, "", | osdadd( TEXT, $colName, $liney, 0, 0, "", | ||
Line 47: | Line 53: | ||
Event( "& | Event( "& | ||
{ | { | ||
+ | // Create the board with max 10 entries. Mode 0 means lowest values at top (Mode 1 is the reverse) | ||
sysHiscoreTable( $kScoreboardName, | sysHiscoreTable( $kScoreboardName, | ||
$entry = sysHiscoreAdd( $kScoreboardName, | $entry = sysHiscoreAdd( $kScoreboardName, | ||
- | *say Bruce added to hiscore, position $entry | ||
$entry = sysHiscoreAdd( $kScoreboardName, | $entry = sysHiscoreAdd( $kScoreboardName, | ||
- | *say Bob added to hiscore, position $entry | ||
$entry = sysHiscoreAdd( $kScoreboardName, | $entry = sysHiscoreAdd( $kScoreboardName, | ||
- | *say Jim added to hiscore, position $entry | ||
$entry = sysHiscoreAdd( $kScoreboardName, | $entry = sysHiscoreAdd( $kScoreboardName, | ||
- | *say Frank added to hiscore, position $entry | ||
} | } | ||
Event( "& | Event( "& | ||
{ | { | ||
- | HiscoreDisplay() | + | HiscoreDisplay( |
} | } | ||
+ | </ | ||
+ |
scripting/samples/hiscoretable.1681752165.txt.gz · Last modified: 2023/04/17 12:22 by mit