Trunk Scripting

From Tronwiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
Coming soon
+
Branch
 +
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>

Revision as of 01:13, 12 December 2009

Branch

lp:~armagetronad-ct/armagetronad/armagetronad-ct


Sample Scripts

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.") 
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.")
Personal tools