PythonScript
| Kind | class |
| Package | psychlua |
| Full name | psychlua.PythonScript |
| Source | source/psychlua/PythonScript.hx |
| Compiled when | #if PYTHON_ALLOWED |
A Python script running inside the engine, powered by the pure-Haxe
Hython interpreter (haxelib hython). Mirrors FunkinLua's API so Python
mods behave exactly like Lua mods: define top-level def callbacks
(onCreate, onUpdate, goodNoteHit, ...), call the same engine functions and
return the same sentinels (Function_Stop, Function_Continue,
Function_StopAll).
Public fields
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
Function_Stop | Dynamic | yes | "##PSYCHLUA_FUNCTIONSTOP" | #if PYTHON_ALLOWED · Sentinel strings are intentionally the SAME values as FunkinLua's so the existing ret != FunkinLua.Function_Stop checks keep working for Python. |
Function_Continue | Dynamic | yes | "##PSYCHLUA_FUNCTIONCONTINUE" | #if PYTHON_ALLOWED |
Function_StopAll | Dynamic | yes | "##PSYCHLUA_FUNCTIONSTOPLUA" | #if PYTHON_ALLOWED |
Function_StopLua | Dynamic | yes | "##PSYCHLUA_FUNCTIONSTOPLUA" | #if PYTHON_ALLOWED · Lua-compatible alias (#51): the documentation and the shared hook table tell Python authors to return Function_StopLua; it carries the same sentinel, so PlayState's Function_StopAll comparison matches it. |
scriptName | String | no | '' | #if PYTHON_ALLOWED |
modFolder | String | no | null | #if PYTHON_ALLOWED |
closed | Bool | no | false | #if PYTHON_ALLOWED |
lastCalledFunction | String | no | '' | #if PYTHON_ALLOWED |
lastCalledScript | PythonScript | yes | null | #if PYTHON_ALLOWED |
sandboxed | Bool | no | false | #if PYTHON_ALLOWED · Runtime half of the softmod sandbox; set before Hython is created. |
securityModName | String | no | null | #if PYTHON_ALLOWED |
securityAllowlist | Array<String> | no | [] | #if PYTHON_ALLOWED |
customFunctions | Map<String, Dynamic> | yes | [] | #if PYTHON_ALLOWED |
registeredFunctions | Map<String, Dynamic> | yes | [] | #if PYTHON_ALLOWED |
Public methods
new (constructor)
function new(scriptName:String, ?scriptCode:String)
Only compiled when #if PYTHON_ALLOWED.
| Parameter | Type | Default |
|---|---|---|
scriptName | String | — |
scriptCode (optional) | String | — |
call
function call(func:String, args:Array<Dynamic>):Dynamic
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
func | String | — |
args | Array<Dynamic> | — |
set
function set(variable:String, data:Dynamic)
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
variable | String | — |
data | Dynamic | — |
reportSecurityRuntime
function reportSecurityRuntime(capability:String, line:Int = 0):String
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
Log a runtime guard failure to both the mod console and process log.
| Parameter | Type | Default |
|---|---|---|
capability | String | — |
line (optional) | Int | 0 |
allowsSecurityRule
inline function allowsSecurityRule(rule:String):Bool
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
rule | String | — |
allowClassAccess
function allowClassAccess(className:String):Bool
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
className | String | — |
get
function get(variable:String):Dynamic
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
variable | String | — |
stop
function stop()
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
pyTrace
function pyTrace(text:String, ignoreCheck:Bool = false, deprecated:Bool = false, color:FlxColor = FlxColor.WHITE)
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
text | String | — |
ignoreCheck (optional) | Bool | false |
deprecated (optional) | Bool | false |
color (optional) | FlxColor | FlxColor.WHITE |
getVar
function getVar(variable:String):Dynamic
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
variable | String | — |
registerFunction
static function registerFunction(name:String, func:Dynamic):Void
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
name | String | — |
func | Dynamic | — |
isOfTypes
static function isOfTypes(value:Any, types:Array<Dynamic>)
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
| Parameter | Type | Default |
|---|---|---|
value | Any | — |
types | Array<Dynamic> | — |
getInstanceStatic
static inline function getInstanceStatic()
Only compiled when #if PYTHON_ALLOWED + #if ACHIEVEMENTS_ALLOWED Achievements.addPythonCallbacks(this); #end + #if DISCORD_ALLOWED DiscordClient.addPythonCallbacks(this); #end + #if flxanimate FlxAnimateFunctions.implementPython(this); #end.
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
interp | Interp | no |
parser | Parser | no |
_missingCalls | Map<String, Bool> | no |
| Method |
|---|
static function preprocessHythonCode(code:String):String |
static function getErrorString(e:Error):String |
function registerCustomFunctions() |
function addLocalCallback(name:String, myFunction:Dynamic) |
function getInstance():Dynamic |
inline function getTextObject(name:String):FlxText |
function getGroupStuff(leArray:Dynamic, variable:String) |
function setGroupStuff(leArray:Dynamic, variable:String, value:Dynamic) |
function loadFrames(spr:FlxSprite, image:String, spriteType:String) |
function resetTextTag(tag:String) |
function resetSpriteTag(tag:String) |
function cancelTween(tag:String) |
function tweenPrepare(tag:String, vars:String) |
function cancelTimer(tag:String) |
static function addAnimByIndices(obj:String, name:String, prefix:String, indices:String, framerate:Int = 24, loop:Bool = false) |