Skip to content

Scripting

Barış Yıldırım edited this page Feb 22, 2025 · 10 revisions

You can directly call any function with “@:hscriptVariable” macros from within the project.

image

Std Classes

You can use Haxe's std classes.

Example

import sys.FileSystem;

FileSystem.readDirectory("/system_data").join(","); // eap,priv,common,temp,music_core,settings,nobackup,game,playgo,httpcache,savedata,savedata_prospero

Custom Functions

sceRandomGetRandomNumber(array:Array<cpp.UInt8>):Void;
sceLncUtilLaunchApp(titleId:String, ?userId:Null<Int>, ?appOpt:Int, ?crashReport:Int, ?checkFlag:cpp.lib.LncAppParamFlag):Int;
sceSystemServiceLaunchWebBrowser(url:String):Bool;
statvfs(path:String):Null<cpp.lib.sys.StatVFSTypedef>;
statvfs_formatted(path:String):Null<{ used:haxe.Int64, total:haxe.Int64, free:haxe.Int64, available:haxe.Int64 }>;
sceKernelGetCpuTemperature():Int;
sceKernelGetCpuFrequency():Float;
sceKernelSendNotificationRequest(message:String):Void;
sceKernelGetHwModelName():String;
sceKernelGetHwSerialNumber():String;
sceKernelGetSocSensorTemperature(?sensor:Int):Int;
sceKernelGetAppInfo(pid:cpp.PidT):cpp.extern.AppInfoTypedef;
sceKernelGetAppCategoryType(pid:cpp.PidT):cpp.extern.ApplicationCategoryType;
statfs(path:String):Null<cpp.lib.sys.StatFSTypedef>;
sysctlbyname(key:String):Null<haxe.io.Bytes>;

Samples

Hello World

sceKernelSendNotificationRequest("Hello World");

Kernel Boot Time

import haxe.io.BytesInput;

var bytes = sysctlbyname("kern.boottime");
var bytesInput = new BytesInput(bytes);
Date.fromTime(bytesInput.readInt32() * 1000);

Temperature Notification

var cpuTemp = sceKernelGetCpuTemperature();
var socTemp = sceKernelGetSocSensorTemperature(0);
sceKernelSendNotificationRequest('CPU temp: ${cpuTemp} °C\nSoC temp: ${socTemp} °C');

sceRandomGetRandomNumber

var array = [0,0,0,0,0,0];
sceRandomGetRandomNumber(array);
return array; // [252,79,72,37,82,252]

SQLite

import hx.well.facades.DBStatic;

var db = DBStatic.connection("app");
var resultSet = db.query('SELECT titleName FROM tbl_contentinfo WHERE titleId = ?', ["PPSA01325"]);
var result = resultSet.next();
result.titleName; // ASTRO's PLAYROOM