Log In  
Follow
shiftalow

I like pixeled graphics and chiptune sound game.
I just released a pico-8 game on Steam!
https://store.steampowered.com/app/1448220

KNUTIL Scene Manager Library
by shiftalow
pelogen (3D modeling tool)
by shiftalow

Cart #knutil_tbfill-0 | 2022-09-12 | Code ▽ | Embed ▽ | Forks ▽ | No License

Feature Overview

TBFILL() Create a table by specifying an index number.

  • Create the table with the specified minimum and maximum indices and fill it with the value of the first argument.
  • Multi-dimensional tables can be created by adding minimum and maximum arguments.
  • This function consumes 30 Token.
-- one-dimensional table 
t=tbfill('yes',1,3)
?t[1]..' '..t[2]..' '..t[3].."\n\n"

-- two-dimensional table
t=tbfill('yes',1,2,1,3)
t[2][2]='no'
?t[1][1]..' '..t[1][2]..' '..t[1][3]
?t[2][1]..' '..t[2][2]..' '..t[2][3]

This function is included in the KNUTIL library.

release note


v0.3

  • changed to specify elements for table start and end, variable length arguments supported

v0.2

  • defaults to 1 or specifies the start of the table

v0.1

  • first release
P#59934 2022-09-12 09:27

Cart #knutil_join-1 | 2022-09-10 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

Feature Overview

JOIN() Join strings with a delimiter.

  • Joins the argument strings with the specified delimiter.
  • This function consumes 25 Token.
?join('====','----','----','----','----\n')

?join(' ',unpack({'test','[join]','is','ok!\n\n'}))

?join('\fa◆\f6','c','o','m','p','l','e','t','e\n')

?join('\-e=\-e',unpack(split('----------------------------','')))

This function is included in the KNUTIL library.

release note


v0.2

  • variable argument support by tuple

v0.1

  • first release
P#59961 2022-09-10 15:45 ( Edited 2022-09-10 16:08)

Cart #knutil_ttable-1 | 2022-08-28 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

Feature Overview

TTABLE() returns the table if the argument is a table.

  • Returns FALSE if not a table.
  • Use when table or string determination is required.
    • (e.g., when using a string for initialization and replacing it with a table)
  • This function consumes 12 Token.
tbl = '1 5 10' -- Default value.

tbl = ttable(tbl) or split(tbl, ' ') -- tbl = {1, 5, 10}

----
----

-- Thereafter, the tbl is not initialized even if there are changes to the elements of the tbl.
tbl = ttable(tbl) or split(tbl, ' ')

This function is included in the KNUTIL library.

release note


v0.1

  • first release

P#60009 2022-08-28 06:03 ( Edited 2022-08-29 02:47)

Cart #knutil_replace-0 | 2022-08-15 | Code ▽ | Embed ▽ | Forks ▽ | No License
4

Feature Overview

REPLACE() Replaces the specified string with the specified string.

  • The first argument string replaces all matches to the second argument string with the third argument string.
  • This function consumes 53 Token.
--"str" becomes "string for replace".
str = replace('[test] for replace', '[test]', 'string') 

This function is included in the KNUTIL library.

release note


v0.1

  • first release

P#60157 2022-08-15 08:06

Cart #tuple_sum-0 | 2022-07-26 | Code ▽ | Embed ▽ | Forks ▽ | No License
2

Feature Overview

SUM() returns the sum of the numbers in the given arguments.

  • If the argument contains nil or false, the result will not be correct.
  • If too many arguments are given, Out of memory is returned. (In the sample, up to 710 arguments)
  • This function consumes 15 Token.

If you are concerned about some of the problems, consider using the "More Argments Ver" code.

--more argments ver(17 token)
function sum(a,...)
 foreach({...},function(v)
  a+=v
 end)
 return a
end

Other tuple trick code: INRNG()

P#63121 2022-07-26 09:26

[sfx]

This is one of the pieces of music played in my own game. ☺

P#63123 2022-07-08 02:19 ( Edited 2022-07-08 02:20)

Cart #knutil_inrng-2 | 2022-06-30 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

Feature Overview

INRNG() Tests if the value is between the lowest and highest values.

  • Tests that the specified value is within a range.
  • This function consumes 10 Token.
--[true] in range value
inrng(5,1,10) 

--[true] lowest range value
inrng(1,1,10)

--[true] highest range value
inrng(10,1,10)

--[false] out of range value
inrng(0,1,10)

This function is included in the KNUTIL library.

release note


v0.2

  • change arguments to a tuple

v0.1

  • first release

P#69481 2022-06-30 01:57 ( Edited 2022-06-30 11:41)

One-off characters [8 chars of raw binary data] print unnaturally.

Or I may not understand this feature.
I was aware that "\^.00000000" would print nothing.

P#71332 2022-04-17 12:38 ( Edited 2022-04-18 14:05)

Setting Tab stop controll code to 0 and outputting tab characters at the same time causes pico-8 crash.

pico-8 version:0.2.4b

print("\^s0\t")
P#72157 2022-04-05 13:53

Cart #rceach-0 | 2022-03-30 | Code ▽ | Embed ▽ | Forks ▽ | No License

Feature Overview

RCEACH() performs a two-dimensional loop in a single function.

  • The rectangle value arguments correspond to [table] {x,y,w,h} and [string] "x y w h".
  • You can refer to the current x and y values in the specified function.
  • This function consumes 50 Token.
rceach({16,16,32,32},function(x,y,r)
 local c=(x+y)%8+8
 pset(x,y,c)
end)

One of KNUTIL's functions, the object generated by EXRECT(), has a rectangle value format to be used for the RCEACH() argument.
may want to Use DMP() if check the converted table.
This function is included in the KNUTIL library.

P#72450 2022-03-30 10:32 ( Edited 2022-06-30 04:10)

Cart #tablemap-0 | 2022-03-21 | Code ▽ | Embed ▽ | Forks ▽ | No License

Feature Overview

TMAP(), like foreach(), applies the function of the second argument to each element of the table.

  • Usage is almost the same as foreach(), plus index values can be referenced within the function.
  • The specified table is returned. (TMAP() nested functions can be applied multiply)
  • The return value in the function specified in the argument can update each element of the table.
  • This function consumes 27 Token.
local t={
 'toast'
 ,'letus'
 ,'bacon'
 ,'cheese'
}
t=tmap(t, function(v,i)
 ?i..'..'..v
end)

--------

t=tmap(t, function(v,i)
 v='super★'..v
 ?i..'..'..v
 return v
end)

--------

t=tmap({
 'shield'
 ,'armor'
 ,'sword'
 ,'ring'
}, function(v,i)
 v=t[i]..'•'..v
 ?i..'..'..v
 return v
end)

may want to Use DMP() if check the converted table.
This function is included in the KNUTIL library.

P#77195 2022-03-21 08:51

Cart #combine_table-0 | 2022-03-15 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

Feature Overview

COMB() combines two tables to create a hash table.

  • Returns the joined table.
  • The two arguments must be tables of index arrays.
  • The argument is nondestructive.
  • Hash tables are not in constant order. (This is a Lua specification.)
  • This function consumes 26 Token.
local keys={'name','species','home','skill'}
local values={'ruth','fox','port town','kon-psi'}

local charcter=comb(keys,values)

may want to Use DMP() if check the converted table.
This function is included in the KNUTIL library.

P#108664 2022-03-15 14:40

Cart #concat___table-0 | 2022-03-11 | Code ▽ | Embed ▽ | Forks ▽ | No License

Feature Overview

CAT() concatenates two or more tables.

  • The second and subsequent arguments are added to the table elements of the first argument.
  • Returns a concatenated table.
  • The table used for the first argument is updated. (destructive)
  • This function consumes 39 Token.
local tbl_1 = {'a'}
local tbl_2 = {'b', 'c'}

cat(tbl_1, tbl_2)

?tbl_1[1] -- a
?tbl_1[2] -- b
?tbl_1[3] -- c

-- Only primary elements can be cloned by specifying an empty table for the first argument.
local tbl = {1, 2, 3}
local tbl_dup = cat({}, tbl)
tbl[1] = 256

?tbl_dup[1] -- 1
?tbl_dup[2] -- 2
?tbl_dup[3] -- 3

See the code in the cartridge for further examples.

may want to Use VDMP() if check the converted table.
This function is included in the KNUTIL library.

P#88288 2022-03-11 14:12 ( Edited 2022-09-10 08:29)

Hello.

I want to use the clipboard to paste SFX data to another console as shown in the image below.
With the current (0.2.4b) function of PICO-8, you can only paste SFX data on the same console.
It would be simpler to share sound effects if they could be pasted to the clipboard in a format like
[gfx] wwhhpp... [/gfx)

P#107590 2022-02-27 15:26 ( Edited 2022-02-28 01:01)

In what situations do you use these conversions?

hexnumber = '3xz'

--A
tonum(hexnumber,1)       : 768 (0x0300.0000)

--B
tonum("0x"..hexnumber,4) : 0 (0x0000.0000)

--C
tonum('0x'..hexnumber)   : -- NO VALUE --([nil])

Example
I want "nil" to be returned when I use a character as an identifier. Therefore, I use the "C" conversion.

hexstr = '108000789$'
hexval = TONORM(hexstr) -- Normalize the value [number boolian nil], otherwise it remains a string.
hextable = {}

if type(hexval) == 'string' then

 foreach(split(hexstr, 3), function(v)
  add(hextable, tonum('0x' .. v))
 end)

end

-- Handle hexadecimal conversions without being converted to numbers by normalization.
-- Only the value of number is stored in the hextable.
-- "$" is not stored.
P#90457 2022-02-24 10:36

I noticed that split() splits the table at the first character if you use a separator of more than two characters.
Is it a bug or a specification that split() cannot be used with separators of more than two characters?

Thank you.


If there is no limit to the number of characters in the separator, string replacement can be implemented in a compact way. (as in replace_short())

function replace_short(s,f,r)
  return join(split(s,f),r or '')
end
-- join() is custom function

function replace(s,f,r)
 local a=''
 while #s>0 do
  local t=sub(s,1,#f)
  a=a..(t~=f and sub(s,1,1) or r or '')
  s=sub(s,t==f and 1+#f or 2)
 end
 return a
end

P#107090 2022-02-17 13:37

Cart #knutil-6 | 2022-09-12 | Code ▽ | Embed ▽ | Forks ▽ | License: CC4-BY-NC-SA
8

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.

Using SCENE

Create a SCENE ( MKSCENES )

SCENES = MKSCENES( { 'UPD', 'DRW', 'KEY' } )

SCENES: Contains the generated SCENEs.

Enter an ORDER into a SCENE ( CMDSCENES )

CMDSCENES([[
[SCENE NAME] [COMMAND] [FUNCTION NAME] [DURATION FRAME]
[SCENE NAME] [COMMAND] [FUNCTION NAME] [DURATION FRAME]
...
]])
  • [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.

CAT: Concatenate tables. Indexes are added last and identical keys are overwritten.

Cart #concat___table-0 | 2022-03-11 | Code ▽ | Embed ▽ | Forks ▽ | No License

COMB: Combines two tables to create a hash table.

Cart #combine_table-0 | 2022-03-15 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

DMP: Dumps information about a variable.

Cart #vdmplua-2 | 2022-03-30 | Code ▽ | Embed ▽ | Forks ▽ | No License

HTBL: Converting a string to a table(Multidimensional Array / Hash Table / Jagged Arrays)

Cart #stringhashtable-3 | 2022-07-30 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

INRNG: Tests that the specified value is within a range.

Cart #knutil_inrng-2 | 2022-06-30 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

JOIN: Joins strings with a delimiter.

Cart #knutil_join-1 | 2022-09-10 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

RCEACH: Iterate from rectangle values.

Cart #rceach-0 | 2022-03-30 | Code ▽ | Embed ▽ | Forks ▽ | No License

REPLACE: Perform string substitutions.

Cart #knutil_replace-0 | 2022-08-15 | Code ▽ | Embed ▽ | Forks ▽ | No License
4

TMAP: More compact operable foreach iterator.

Cart #tablemap-0 | 2022-03-21 | Code ▽ | Embed ▽ | Forks ▽ | No License

TBFILL: Creates a table filled with the specified values.

Cart #knutil_tbfill-0 | 2022-09-12 | Code ▽ | Embed ▽ | Forks ▽ | No License

TTABLE: If the argument is a table, the table is returned.

Cart #knutil_ttable-1 | 2022-08-28 | Code ▽ | Embed ▽ | Forks ▽ | No License
1

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".
TTOH: Sum the numbers in argument 1 by shifting bits to argument 2.
HTOT: Divide an integer value into 8 bits and make it into a table.
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.
SLICE: Cuts out the table at the specified index.
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.

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
  • example: Add htbl() example use
P#59538 2021-03-03 12:49 ( Edited 2022-09-12 09:35)

Hello, everyone.

A few days ago, a game I created called KONSAIRI was released on Steam!
http://store.steampowered.com/app/1448220/

There are still very few examples of PICO-8 games on the Steam platform as PICO-8 games.

I think that's because, as content, PICO8 titles are seen as lacking when compared to other game engines and those created in a free development environment with no restrictions.

But I challenge you to dream of being in the same store as a masterpiece game, despite its limitations.

I also wish to see more interest in PICO-8 in my part of Japan.

[0x0]

P#83569 2020-11-01 14:36

Hello.

Suggestion.
I would like the exported file to include the current config.txt (global_config.txt) as local_config.txt in the exported file.

This will allow us to play from the creator's ideal config in another user's environment.

"global_config.txt" refers to the config.txt that I've been using.
If both global_config.txt and local_config.txt exist, local_config.txt is assumed to take precedence.

Sequence of events


I recently released the PICO-8 app in executable format.
However, the user's environment that downloaded it had different operations and a lower frame rate for inactive windows.
The released manual had to be rewritten and the creator was unable to provide the ideal play environment.

A question thread containing this
https://www.lexaloffle.com/bbs/?tid=39940

P#83100 2020-10-19 03:47

Is there a recommended coding method that would eliminate the drop frames that occur when the pico8 window is turned to the back?
Or is there a memory address I can set?

I want to keep the number of times to execute _update60() and draw() the same, even at 30fps.

P#83056 2020-10-18 03:05

View Older Posts
Follow Lexaloffle:        
Generated 2022-10-04 01:26:58 | 0.082s | Q:79