Trunk Scripting

From Tronwiki
(Difference between revisions)
Jump to: navigation, search
(Classes)
(Classes)
Line 66: Line 66:
 
{{ClassFunction|set_all(bool on)| All ladderlog messages on or off}}
 
{{ClassFunction|set_all(bool on)| All ladderlog messages on or off}}
 
{{FunctionParameter|on|All ladderlog messages On or off}}
 
{{FunctionParameter|on|All ladderlog messages On or off}}
{{ClassFunction|set_callback(function)|set_callback(function func)}}
+
{{ClassFunction|set_callback(function func)|Callback function}}
 
{{FunctionParameter|func|the function you declare}}
 
{{FunctionParameter|func|the function you declare}}

Revision as of 05:17, 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.")

Classes

armagetronad.LadderLogWriter - Ladderlog stuff

  • get_writer(string llog) - Read ladderlog
    • llog - The ladderlog message you wish to recieve
  • is_enabled() - is_enabled()
  • set_all(bool on) - All ladderlog messages on or off
    • on - All ladderlog messages On or off
  • set_callback(function func) - Callback function
    • func - the function you declare
Personal tools