Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739
Crazy Tronners Wiki - Trunk Scripting

Trunk Scripting

From Tronwiki
Jump to: navigation, search
(Classes)
Line 2: Line 2:
 
  lp:~armagetronad-ct/armagetronad/armagetronad-ct
 
  lp:~armagetronad-ct/armagetronad/armagetronad-ct
  
 
==Sample Scripts==
 
 
<pre>
 
print("Start scripting initialization.")
 
 
import sys, os
 
print os.getcwd()
 
sys.path.append('./src/swig/ext/')
 
import armagetronad
 
 
ci = armagetronad.tConfItemBase.FindConfigItem("CYCLE_SPEED")
 
 
def round_winner(args):
 
    print "start round winner ladder log writer callback"
 
    armagetronad.tConfItemBase.LoadString("CYCLE_SPEED 100")
 
    print args
 
    print "end round winner ladder log writer callback"
 
 
rw=armagetronad.ladder_log_writer.get_writer("ROUND_WINNER")
 
if rw.is_enabled():
 
    rw.setCallback(round_winner)
 
    print "round_winner enabled!"
 
 
print("End scripting initialization.")
 
</pre>
 
<pre>
 
print("Start scripting initialization.")
 
 
import sys, os
 
print os.getcwd()
 
sys.path.append('./src/swig/ext/')
 
import armagetronad
 
 
def player_entered(args):
 
    p=args[1]
 
    print args
 
 
def round_winner(args):
 
    p=args[1]
 
    print args
 
    print("PLAYER_MESSAGE "+p+' "Congratulation from script '+p+' !"')
 
    armagetronad.ConfItemBase.LoadString("PLAYER_MESSAGE "+p+' "Congratulation from script '+p+' !"')
 
    ci = armagetronad.ConfItemBase.FindConfigItem("CYCLE_SPEED")
 
    print "cycle_speed " + ci.WriteVal()
 
    ci.ReadVal("20")
 
 
def script_config(args):
 
    print ">", args
 
 
t = armagetronad.ConfItemScript("TEST_SCRIPT", script_config)
 
 
armagetronad.LadderLogWriter.get_writer("ROUND_WINNER").set_callback(round_winner)
 
armagetronad.LadderLogWriter.get_writer("PLAYER_ENTERED").set_callback(player_entered)
 
 
print("End scripting initialization.")
 
</pre>
 
 
==Enums==
 
==Enums==
 
{{ClassSetting|AccessLevel|enumeration used to check authentication level}}
 
{{ClassSetting|AccessLevel|enumeration used to check authentication level}}
Line 317: Line 260:
 
   real lag()        //!< expected average network latency
 
   real lag()        //!< expected average network latency
 
   real lag_threshold()      //!< tolerated network latency variation
 
   real lag_threshold()      //!< tolerated network latency variation
 +
 +
==Sample Scripts==
 +
 +
<pre>
 +
print("Start scripting initialization.")
 +
 +
import sys, os
 +
print os.getcwd()
 +
sys.path.append('./src/swig/ext/')
 +
import armagetronad
 +
 +
ci = armagetronad.tConfItemBase.FindConfigItem("CYCLE_SPEED")
 +
 +
def round_winner(args):
 +
    print "start round winner ladder log writer callback"
 +
    armagetronad.tConfItemBase.LoadString("CYCLE_SPEED 100")
 +
    print args
 +
    print "end round winner ladder log writer callback"
 +
 +
rw=armagetronad.ladder_log_writer.get_writer("ROUND_WINNER")
 +
if rw.is_enabled():
 +
    rw.setCallback(round_winner)
 +
    print "round_winner enabled!"
 +
 +
print("End scripting initialization.")
 +
</pre>
 +
<pre>
 +
print("Start scripting initialization.")
 +
 +
import sys, os
 +
print os.getcwd()
 +
sys.path.append('./src/swig/ext/')
 +
import armagetronad
 +
 +
def player_entered(args):
 +
    p=args[1]
 +
    print args
 +
 +
def round_winner(args):
 +
    p=args[1]
 +
    print args
 +
    print("PLAYER_MESSAGE "+p+' "Congratulation from script '+p+' !"')
 +
    armagetronad.ConfItemBase.LoadString("PLAYER_MESSAGE "+p+' "Congratulation from script '+p+' !"')
 +
    ci = armagetronad.ConfItemBase.FindConfigItem("CYCLE_SPEED")
 +
    print "cycle_speed " + ci.WriteVal()
 +
    ci.ReadVal("20")
 +
 +
def script_config(args):
 +
    print ">", args
 +
 +
t = armagetronad.ConfItemScript("TEST_SCRIPT", script_config)
 +
 +
armagetronad.LadderLogWriter.get_writer("ROUND_WINNER").set_callback(round_winner)
 +
armagetronad.LadderLogWriter.get_writer("PLAYER_ENTERED").set_callback(player_entered)
 +
 +
print("End scripting initialization.")
 +
</pre>

Revision as of 20:48, 19 January 2010

Personal tools