Trunk Scripting

From Tronwiki
Revision as of 04:42, 12 December 2009 by Kyle (Talk | contribs)
Jump to: navigation, search

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

Classes

armagetronad.LadderLogWriter get_writer(string) is_enabled() set_all(bool) set_callback(function)

Personal tools