Trunk Scripting

From Tronwiki
(Difference between revisions)
Jump to: navigation, search
(Classes)
Line 60: Line 60:
 
</pre>
 
</pre>
 
==Classes==
 
==Classes==
'''armagetronad.LadderLogWriter'''
+
{{ClassSetting|armagetronad.LadderLogWriter|Ladderlog stuff| }}
get_writer(string)
+
{{ClassFunction|get_writer(string llog)| Read ladderlog}}
is_enabled()
+
{{FunctionParameter|llog|The ladderlog message you wish to recieve}}
set_all(bool)
+
{{ClassFunction|is_enabled()|is_enabled()}}
set_callback(function)
+
{{ClassFunction|set_all(bool on)| All ladderlog messages on or off}}
 +
{{FunctionParameter|on|All ladderlog messages On or off}}
 +
{{ClassFunction|set_callback(function)|set_callback(function func)}}
 +
{{FunctionParameter|func|the function you declare}}

Revision as of 05:16, 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) - set_callback(function func)
    • func - the function you declare
Personal tools