Skip to content

Useful Things

Nenkai edited this page Jul 14, 2024 · 4 revisions

Calling a function with a delay

context.addTimeOut("myFunctionTimeout", (context) => 
{
    // ...
}, context);
context.setTimeOut("myFunctionTimeout", 0.5); // Will be called in 0.5s

Loading a script into current module

<module>.load("path_to_script"); // no .adc extension

Playing a SFX

main::sound.play(sfx_name); // i.e "cursor"

Opening a dialog

DialogUtil::openConfirmDialog(context, DialogUtil::..., message);

Setting Current Cursor

CursorUtil::setCursor(context, cursor_name);

Localized Text

GT5

// GT4/5
// Get the specified string at specified category & key
context.translate(category, key); 

// Page & category are combined i.e MyRoot::MyCategory)
context.translate(page, category, mode);

GT6

manager.translate(category, key);

UI

Iterating through widget composites (lists)

for (var it = <widget>.first; it != nil; it = it.next_widget)
{
    // ...
}

Setting Focus on a Widget

<module>.setFocus(widget); // example: ROOT.setFocus(my_widget);

Waiting

context.wait(seconds_float) // example: 0.5
Clone this wiki locally