Call BASIC and native Godot helpers
BASIC IN YOUR GAME
A function can belong to another BASIC record, or to a PCA Script, Lua or GDScript record. The caller needs the record ID, function name and arguments in the right order.
FUNCTION Run()
DIM total = CallScript("ticket_price", "Fare", [3, 4], {})
RETURN total
END FUNCTIONThe arguments are [3, 4]. The last {} is the optional context dictionary. This call to Fare returns 12. The script record and function can have different names.
When you need a Godot API#
Put this listing in a native GDScript record with ID native_screen. It asks Godot for the width of the visible game viewport.
func Width() -> int:
return int(Runtime.get_viewport().get_visible_rect().size.x)Put the following in a BASIC record. Let GDScript handle the engine object and return a plain number to BASIC.
FUNCTION Run()
RETURN CallScript("native_screen", "Width", [], {})
END FUNCTIONWhat you should see The Linux preview returned 1280. Another window or device can have a different width. To run a visual graph, BASIC also accepts RUN VISUAL SCRIPT "graph_id" with a matching graph ID.
