Difference between revisions of "SDK 6.3/PAWN/Core"
(Official WOWCube SDK 6.3 documentation (automated publish from SDK headers)) |
(Mark PAWN API as legacy (supported, not developed) (WowBot)) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{notice|'''Official WOWCube SDK documentation.''' SDK 6.3, PAWN API. Generated from the canonical SDK headers — do not edit by hand; regenerate from source.}} | {{notice|'''Official WOWCube SDK documentation.''' SDK 6.3, PAWN API. Generated from the canonical SDK headers — do not edit by hand; regenerate from source.}} | ||
| + | {{notice|'''Legacy track.''' The PAWN API is supported but no longer actively developed — the last PAWN additions shipped in SDK 6.2. New development uses the [[SDK 6.3/C++/Native API|C++ (WebAssembly) API]].}} | ||
| + | |||
| + | {{SDK 6.3 nav}} | ||
| + | |||
| + | ''← [[SDK 6.3]] · PAWN / Core'' | ||
==Constants and defines== | ==Constants and defines== | ||
| Line 60: | Line 65: | ||
:* patch - increment when bugfix shipped | :* patch - increment when bugfix shipped | ||
| − | See also: getAppVersion() | + | See also: [[#getAppVersion|getAppVersion()]] |
History: | History: | ||
| Line 85: | Line 90: | ||
:: array with the save data | :: array with the save data | ||
| − | See also: GAME_SAVE_SIZE, loadState() | + | See also: [[#GAME_SAVE_SIZE|GAME_SAVE_SIZE]], [[#loadState|loadState()]] |
History: | History: | ||
| Line 101: | Line 106: | ||
: calculations and rendering complexities. | : calculations and rendering complexities. | ||
| − | See also: ON_PhysicsTick(), ON_Render() | + | See also: [[#ON_PhysicsTick|ON_PhysicsTick()]], [[SDK 6.3/PAWN/Graphics#ON_Render|ON_Render()]] |
===ON_PhysicsTick=== | ===ON_PhysicsTick=== | ||
| Line 132: | Line 137: | ||
:: array with a message data | :: array with a message data | ||
| − | See also: broadcastPacket() | + | See also: [[#broadcastPacket|broadcastPacket()]] |
History: | History: | ||
| Line 155: | Line 160: | ||
:: array with the save data | :: array with the save data | ||
| − | See also: GAME_SAVE_SIZE, loadState(), saveState() | + | See also: [[#GAME_SAVE_SIZE|GAME_SAVE_SIZE]], [[#loadState|loadState()]], [[#saveState|saveState()]] |
History: | History: | ||
| Line 171: | Line 176: | ||
: and will be termintated after that period. No more handlers will be called. | : and will be termintated after that period. No more handlers will be called. | ||
| − | See also: saveState() | + | See also: [[#saveState|saveState()]] |
History: | History: | ||
| Line 213: | Line 218: | ||
: Quit from the application. | : Quit from the application. | ||
| − | See also: SENSITIVITY_MENU_CHANGE_SCRIPT | + | See also: [[#SENSITIVITY_MENU_CHANGE_SCRIPT|SENSITIVITY_MENU_CHANGE_SCRIPT]] |
===toggleDebugInfo=== | ===toggleDebugInfo=== | ||
| Line 237: | Line 242: | ||
:: size of the packet data in cells | :: size of the packet data in cells | ||
| − | See also: ON_Packet(), MAX_PACKET_TYPES, MAX_PACKET_SIZE | + | See also: [[#ON_Packet|ON_Packet()]], [[#MAX_PACKET_TYPES|MAX_PACKET_TYPES]], [[#MAX_PACKET_SIZE|MAX_PACKET_SIZE]] |
History: | History: | ||
| Line 260: | Line 265: | ||
: True if save was successful. | : True if save was successful. | ||
| − | See also: GAME_SAVE_SIZE, ON_Load(), loadState() | + | See also: [[#GAME_SAVE_SIZE|GAME_SAVE_SIZE]], [[#ON_Load|ON_Load()]], [[#loadState|loadState()]] |
History: | History: | ||
| Line 274: | Line 279: | ||
: not affect an application performance. | : not affect an application performance. | ||
| − | See also: ON_Load(), saveState() | + | See also: [[#ON_Load|ON_Load()]], [[#saveState|saveState()]] |
===random=== | ===random=== | ||
| Line 310: | Line 315: | ||
:* version - structure describing application version | :* version - structure describing application version | ||
| − | See also: APP_VERSION | + | See also: [[#APP_VERSION|APP_VERSION]] |
History: | History: | ||
| Line 336: | Line 341: | ||
: Requested byte value. | : Requested byte value. | ||
| − | See also: broadcastPacket(), saveState(), ON_Load(), ON_Packet() | + | See also: [[#broadcastPacket|broadcastPacket()]], [[#saveState|saveState()]], [[#ON_Load|ON_Load()]], [[#ON_Packet|ON_Packet()]] |
==Other== | ==Other== | ||
Latest revision as of 09:45, 26 July 2026
SDK 6.3 · PAWN API: Core ·
Graphics ·
Topology ·
Sound ·
Motion Sensor ·
Leaderboard ·
Splash Screen ·
Physics ·
Network ·
Save ·
Scramble ·
Logging
C++: Native API · Application · GFX Engine · Rust: Rust API (experimental) · Changelog
← SDK 6.3 · PAWN / Core
Constants and defines
MODULES_MAX
Syntax:
#define MODULES_MAX 8
Description:
- How many modules there are in the assembled cube.
SCREENS_MAX
Syntax:
#define SCREENS_MAX 3
Description:
- How many screens there are on the each cube module.
SENSITIVITY_MENU_CHANGE_SCRIPT
Syntax:
#define SENSITIVITY_MENU_CHANGE_SCRIPT 6
Description:
- How many shakes required to trigger an application quit. Shake is a
- continuous significant motion which direction has been changed since the
- previous recent significant motion.
GAME_SAVE_SIZE
Syntax:
#define GAME_SAVE_SIZE 64
Description:
- Maximum allowed size of an application save data in cells.
MAX_PACKET_TYPES
Syntax:
#define MAX_PACKET_TYPES 32
Description:
- Maximum number of an application packet types.
MAX_PACKET_SIZE
Syntax:
#define MAX_PACKET_SIZE 28
Description:
- Maximum size of an application packet.
Data structures
APP_VERSION
Syntax:
#define APP_VERSION [.major, .minor, .patch]
Description:
- Array with named fields describing application version.
- Fields:
- major - increment when application significantly changed
- minor - increment when new feature added
- patch - increment when bugfix shipped
See also: getAppVersion()
History:
- v6.0 - added
Event handlers
ON_Init
Syntax:
forward ON_Init(id, size, const pkt[]);
Description:
- Initialization handler.
- Public function with such signature will be called before the application
- loop starts. Useful for a globals initializations, e.g. generating level,
- baking backgrounds, etc. Additionaly save data is provided.
Arguments:
- id
- an id of the save data
- size
- size of the save data in cells
- pkt[]
- array with the save data
See also: GAME_SAVE_SIZE, loadState()
History:
- v5.0 - provide save data in arguments
ON_Tick
Syntax:
forward ON_Tick();
Description:
- Main application loop handler.
- Public function with such signature will be called on each iteration of an
- application loop. Main application logic should be placed here. Frequency
- of calls are not constant and depends on the configured framerate,
- calculations and rendering complexities.
See also: ON_PhysicsTick(), ON_Render()
ON_PhysicsTick
Syntax:
forward ON_PhysicsTick();
Description:
- Uniformly delayed loop handler.
- Public function with such signature will be called approximately each 30
- milliseconds. However time interval between calls can be larger because the
- application is single threaded and complex rendering or calculation can
- delay events processing. Useful for calculations requiring a time delta,
- e.g. sprite movement at a constant speed.
ON_Packet
Syntax:
forward ON_Packet(type, size, const pkt[]);
Description:
- Network packet handler.
- Public function with such signature will be called to handle a received
- application packet from an another module in the cube network.
Arguments:
- type
- an application packet type
- size
- size of the received packet
- pkt[]
- array with a message data
See also: broadcastPacket()
History:
- v6.0 - added
ON_Load
Syntax:
forward ON_Load(id, size, const pkt[]);
Description:
- Asynchronous application save data handler.
- Public function with such signature will be called to handle an application
- save data. It is an asynchronous event so access to flash memory will not
- affect an application performance.
Arguments:
- id
- an id of the save data
- size
- size of the save data in cells
- pkt[]
- array with the save data
See also: GAME_SAVE_SIZE, loadState(), saveState()
History:
- v5.0 - provide data header as arguments rather than first cell
ON_Quit
Syntax:
forward ON_Quit();
Description:
- Application quit handler.
- Public function with such signature will be called to handle an application
- quit event when user did triple shake. Application can shutdown gracefully,
- e.g. save state on the flash memory. Application has 1000ms to run handler
- and will be termintated after that period. No more handlers will be called.
See also: saveState()
History:
- v5.0 - added
Functions
getTime
Syntax:
native getTime();
Description:
- Get time in milliseconds since the module start.
Return values:
- Time in milliseconds since the module start.
getUserName
Syntax:
native getUserName(userName[], size = sizeof(userName));
Description:
- Get the name of a user who is logined on the cube.
- Get the user name configured in the WOWCube mobile application to save
- results for.
Arguments:
- size
- size of string to keep a user name
- Outputs
- userName
- string to keep a user name
See also: USER_NAME_LENGTH
quit
Syntax:
native quit();
Description:
- Quit from the application.
See also: SENSITIVITY_MENU_CHANGE_SCRIPT
toggleDebugInfo
Syntax:
native toggleDebugInfo();
Description:
- Toggle overlay with debug information. TBD - move to GFX
broadcastPacket
Syntax:
native broadcastPacket(type, const data[], size = sizeof(data));
Description:
- Broadcast a packet over the cube network.
Arguments:
- type
- arbitrary packet type
- data[]
- packet data to broadcast
- size
- size of the packet data in cells
See also: ON_Packet(), MAX_PACKET_TYPES, MAX_PACKET_SIZE
History:
- v6.0 - added
saveState
Syntax:
native bool:saveState(const data[], size = sizeof(data));
Description:
- Request to save an application data
- Save user settings and/or progress on the flash to restore next time. Each
- save data has an incremental ID.
Arguments:
- data []
- data to save
- size
- size of data in cells to save
Return values:
- True if save was successful.
See also: GAME_SAVE_SIZE, ON_Load(), loadState()
History:
- v5.0 - fixed a bug in which only part of a data saved on the flash
loadState
Syntax:
native loadState();
Description:
- Request to load an application save data from the flash.
- Trigger state load event. It is asynchronous so access to flash memory will
- not affect an application performance.
See also: ON_Load(), saveState()
random
Syntax:
native random(min, max);
Description:
- Generate random number in half-open range.
- Random number generator is initialized before each application start. Seed
- for initialization is generated by TRNG (True Random Number Generator).
Arguments:
- min
- minimal value of range to generate random number
- max
- maximum value of range to generate random number
Return values:
- Pseudo random value from requested range.
History:
- v5.0 - fixed a bug in which random does not generate numbers in a given
- range.
getAppVersion
Syntax:
native getAppVersion(version[APP_VERSION]);
Description:
- Get application version.
- WOWCube applications follow semantic versioning scheme (see
- https://semver.org). This interface allows to get version parts stored in
- the cube application descriptor.
- Outputs
- version - structure describing application version
See also: APP_VERSION
History:
- v6.0 - added
parseByte
Syntax:
stock parseByte(const arr[], const n)
Description:
- Get arbitrary byte value from array.
- Pawn works with cells which has a size of 4 bytes. Native interfaces
- handling generic data like network messages have size limits for that data.
- If application does not need to work with a large numbers, several values
- can be packed into a single cell. This function provides interface to
- extract such values from array.
Arguments:
- arr
- array to read byte from
- n
- number of byte to read
Return values:
- Requested byte value.
See also: broadcastPacket(), saveState(), ON_Load(), ON_Packet()
Other
SELF_ID
Syntax:
public const SELF_ID = 0;
Description:
- An ID of the module on which application copy is running.