Note: This cartridge's settings do not allow embedded playback. A [Play at lexaloffle] link will be included instead.
Feature Overview
"KNUTIL" is a library for PICO-8 that contains functions that are frequently used in the games I have created.
I've kept the functions that I eventually needed in my production.
In this cart, I show you how the scene functions work with animations.
Z key: Execute the order command.
Up/Down: Select the order command.
SCENE MANAGER controls and replaces the order in which functions are called with a small number of tokens by using consecutive string instructions.
The generated SCENE can register a global function as an ORDER.
One of the registered ORDERS is retrieved by SCENE and the process is repeated for the specified length.
When the processing is finished, it repeats the processing of the next ORDER.
This is expected to facilitate the planning of the performance.
[SCENE NAME] : Specify the name generated by MKSCENES.
[COMMAND] : Specify the following ORDER COMMANDS.
[FUNCTION NAME] : Specify the name of the global function.
[DURATION FRAME]: Specifies the number of frames to be sustained; if set to 0, it will not automatically terminate.
ORDER COMMANDS
ST (SET): Delete all stacked ORDERS in SCENE and set new ORDERS.
CMDSCENES[[
UPD ST MANAGE 0
]]
Clean the SCENE "UPD" and add a "FUNCTION MANAGE".
PS (PUSH): Add an ORDER to the SCENE
CMDSCENES[[
KEY PS KEYCHECK 0
]]
Add the SCENE "KEY" with "FUNCTION KEYCHECK" at the top.
US (UNSHIFT): interrupt ORDER at the beginning of a SCENE.
CMDSCENES[[
DRW US DRAWRECT 200
DRW US NIL 100
DRW US DRAWCIRC 200
]]
Scene "DRW" is executed in the ORDER of DRAWCIRC, NIL, DRAWRECT.
RM (REMOVE): remove one ORDER.
CMDSCENES[[
DRW RM
]]
Removes the first ORDER of the SCENE "DRW".
CMDSCENES[[
DRW RM DRAWRECT
]]
Deletes the DRAWRECT ORDER of SCENE "DRW", starting from the top.
CL (CLEAR): Remove all stacked ORDERS from the SCENE.
CMDSCENES[[
KEY CL
]]
Deletes all the ORDERS registered in the SCENE "KEY".
FI (FIND): Search and retrieve ORDERS from a SCENE.
RES = CMDSCENES[[
DRW FI DRAWRECT
]]
In this case, the return value RES is a table, and the ORDER "DRAWRECT" is in the first element.
Create a function for ORDERS.
FUNCTION KEYCHECK( ORDER )
PRINT('PROCESSIONG ORDER')
END
Run each SCENE.
## In the _UPDATE() and _DRAW() functions
FOR I,V IN PAIRS(SCENES) DO
V.TRA()
END
ORDER function
FUNCTION [FUNCTION NAME] ( ORDER )
CLS()
IF ORDER.FST THEN
STOP"IT'S FIRST!"
END
IF ORDER.LST THEN
STOP"IT'S LAST!"
END
PRINT('COUNT: '..ORDER.CNT..'/'..ORDER.DUR)
END
Properties of ORDER
FST / LST
ORDER.FST : at first execution
ORDER.LST : at the last execution.
CNT / DUR
ORDER.CNT : Execution count of the currently running ORDER.
ORDER.DUR : Count of expected end of the currently running ORDER.
PRM
It contains the value specified in the second argument of CMDSCENES.
RATE
Used to specify the end from the start, e.g. in coordinates.
ORDER.rate('[start] [end]', duration, count )
The default values for duration and count are the ones specified in CMDSCENES.
Force ORDER termination.
Do return 1
or
do ORDER.rm = 1.
Functions other than scenes
There is one in this library that I have already posted.
BPACK: Pack the value of the bit specification with bit width.
Note: This cartridge's settings do not allow embedded playback. A [Play at lexaloffle] link will be included instead.
Functions not posted on BBS. (I will post them some other time)
TONORM: String to type conversion(boolian, nil, number). TOHEX: Convert hexadecimal string without "0x". BPACK: BUNPACK: EXRECT(RFMT): Drawing and overlap judgment with the generated rectangle. TOC: Divide the value and exclude the remainder. SPLIT(wrapper function): Split() for two-dimensional support. Defaults to space separator. HTD: Convert a hexadecimal string to a 4-bit-16-bit table. OUTLINE: Display text with edges. MKPAL: Create a table to be used in pal(), specifying the colors before and after the change. ECMKPAL: Generate a set of tables to be retrieved by MKPAL(). ECPALT: Run palt() on the table. AMID: Expand the arguments to positive and negative and do mid(). BMCH: Compares two values to judge that they both have a bit in common."Bitwise operators" make it less significant.
++ REMOVED ++
TTOH: Sum the numbers in argument 1 by shifting bits to argument 2. This function has been re-specified to BPACK. HTOT: Divide an integer value into 8 bits and make it into a table. This function has been re-specified to BUNPACK. SLICE: Cuts out the table at the specified index. the function was removed because there is a {unpack()} with a similar function.
UPDATE HISTORY
v0.9
tbfill: changed to specify indexes at the beginning and end of tables, support for variable length arguments.
tohex: fixed for update of tbfill()
v0.8
join: use of tuples
tbfill: defaults to 1 or specifies the start of the table
tohex: support for updating join()
v0.7
sceneorder:"rate" func countermeasures against overflow of digits
code update saved token:
htbl: 7 tokens
tonorm: 9 tokens
v0.6
simplified handling of scene orders
rceach: name change from ecxy()
inrng: using tupple twice
exrect.con: name change from exrect.cont()
exrect.hov: name change from exrect.hover()
scenes: order.rate is calculated enough value in the last count
cmdscenes: change name from scenesbat
v0.5
Mainly due to sub()'s CPU cost countermeasure.
replace: fix usage of sub()
htd: Convert from split()
htbl: Run newlines without replace()
scene: Save cost with split()&comb() at initialization
dbg: Change to display values without dbg() argument