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

And More Tools!
[Animation tool]
https://bitchunk.itch.io/spranim-kit
[Music scales and Play the Piano]
https://bitchunk.itch.io/mu-scalelab

KNUTIL Scene Manager & Frequently Used Functions Library
by shiftalow
pelogen (3D modeling tool)
by shiftalow
:: Unfold ::

Cart #knutil_dbg-1 | 2023-08-10 | Code ▽ | Embed ▽ | No License
1

Feature Overview

DBG() Displays any timing value in real time.

  • Executed with arguments, it stacks values for display.
  • You need to specify 'd?' at the timing you want to display.
  • When the stacked value display is complete, it is reset.
  • This function consumes 71 Token.
function _update()
 dbg('Debug Test!',time())
end

function _draw()
 dbg('d?') -- 'Debug Test! [time value]'
end

This function will be included in the next version(0.14.0) of KNUTIL library.
If you want to stop processing and investigate detailed values, consider DMP().

release note


v0.1

  • first release
P#132923 2023-08-10 13:40

:: Unfold ::

Cart #knutil_amid-1 | 2023-08-09 | Code ▽ | Embed ▽ | No License
2

Feature Overview

AMID() Returns the median of a given positive and negative number.

  • It is used in controlling the camera and parameters that can swing either + or -.
  • This function consumes 10 Token.
x,y=0,0
w,h=16,8 -- range of movement(*2+1)
while 1 do
    cls(12)
    camera(-64,-64)

    rectfill(w,h,-w,-h,0)

    ?'⬆️⬇️⬅️➡️ key to move',-60,-60

    x+=tonum(btn(1))-tonum(btn(0))
    x=amid(w,x)

    y+=tonum(btn(3))-tonum(btn(2))
    y=amid(h,y)

    pset(x,y,8)
    ?x..' '..y,-w,h+1,7
    flip()
end

This function will be included in the next version(0.14.0) of KNUTIL library.
If you want to determine that two values are within range, consider INRNG().

release note


v0.1

  • first release
P#132902 2023-08-09 14:42

:: Unfold ::

Cart #knutil_htd-0 | 2023-08-08 | Code ▽ | Embed ▽ | No License

Feature Overview

HTD() Split a continuous string of hexadecimal numbers into a table.

  • the number of supported delimited bits is 4,8,12,16 bits (1~4 nibbles).
  • characters that cannot be converted to numbers are ignored.
    • the result of the api's tonum('0x'..v) of the api.
  • depending on the delimiter, a missing last character will result in a lower digit by the number of missing characters.
  • This function consumes 30 Token.
local a=htd('12a30f',1) -- a={1,2,10,3,0,15}
local b=htd('12a30f',3) -- b={297,783}

Perhaps consider BUNPACK() if you want to separate NUMBER every few bits.

This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#132863 2023-08-08 10:18 ( Edited 2023-08-08 10:25)

:: Unfold ::

Cart #knutil_ecpalt-0 | 2023-08-07 | Code ▽ | Embed ▽ | No License

Feature Overview

ECPALT() set transparency from palette table.

  • Transparency is reset at each function execution.
  • If the value of the "color id key" in the palette table is 0, the palette becomes transparent.
  • The palette that was made black by MKPAL() can be used as transparent as it is.
  • The format is redundant due to the specification to match MKPAL().
  • This function consumes 20 Token.
-- Make 6, 7, and 13 transparent.

ecpalt({[6]=0,[7]=0,[13]=0})

spr(1,16,32,2,2)

This function will be included in the next version(0.14.0) of KNUTIL library.

release note


v0.1

  • first release
P#132688 2023-08-07 15:57

:: Unfold ::

Cart #knutil_mkpal-0 | 2023-08-07 | Code ▽ | Embed ▽ | No License

Feature Overview

MKPAL() Create a color swap table for use in PAL().

  • This is useful for creating several color patterns.
  • It is not an error if the number of elements in the swap table does not match.
  • This function consumes 44 Token.
-- Color swap to darken "blue, white, and green".

local p=mkpal({12,7,11},{13,6,3}) -- mkpal('c7b','d63') is also the same.
pal(p)
spr(1,16,32,2,2)

This function will be included in the next version(0.14.0) of KNUTIL library.

release note


v0.1

  • first release
P#130356 2023-08-07 06:15 ( Edited 2023-08-07 06:51)

:: Unfold ::

Horizontal alignment is reset when a line break or tab is inserted in p8scii.

The example below expects the first line to start at the beginning of the first line after a line break.
Also, the tab position seems to reset the shift cursor.

cls()
?"\+jjtest p8scii\ntest p8scii (𝘹ADJUST:j)",0,0
?"\+ljtest p8scii\ntest p8scii (𝘹ADJUST:l)",0,16

?"\-jtest\-j   p8scii (𝘹ADJUST:j)",0,64
?"\-ltest\-l   p8scii (𝘹ADJUST:l)",0,72

Cart #p8scii_nl_adjust_bug-0 | 2023-05-28 | Code ▽ | Embed ▽ | No License
1

P#130237 2023-05-28 06:18

:: Unfold ::

Cart #knutil_oprint-3 | 2023-07-02 | Code ▽ | Embed ▽ | No License
2

Feature Overview

OPRINT() Adds outlines to text and prints them.

  • enclosure is not possible if tabs or newlines are included. (in pico8_v0.2.5.g)
  • operation cannot be guaranteed if p8scii for decoration is included.
  • Custom decorations other than outlines can be made by specifying a comma-separated p8scii as an argument.
  • This function consumes 33 Token.
-- Split a pair of data and further split it into colors and names.

oprint('outline print',10,6,7,13)  -- text, x, y, foreground-color, outline-color [, custom decoration]

This function is an inheritance of OUTLINE contained in the KNUTIL library.

release note


v0.3

  • add custom decoration argument.

v0.2

  • remove color()

v0.1

  • first release
P#130214 2023-05-27 15:02 ( Edited 2023-07-02 07:01)

:: Unfold ::

When you see the default kana font, you might think that you could create something a little better.
But then you realize that it was a kind of provocation for creators (or designers).

Why the tilt?

Hiragana can be quite difficult to express in 5x5px.
One answer to this problem is a slanted design.
This allowed us to secure a space, albeit a small one, per character.

x4 size

Original size

Preview gif

Text conversion scripts for SpreadSheet custom scripts

This script converts "Kana/Kana" text to "Katamuki kana" specification in a spreadsheet.
Register it in a custom script and execute p8Katamukikana([Cell-ID]) on the cell you want to convert.

function p8Katamukikana(text) {
  const kanamap = {
    'が': 'か゛', 'ぎ': 'き゛','ぐ': 'く゛','げ': 'け゛','ご': 'こ゛',
    'ざ': 'さ゛', 'じ': 'し゛','ず': 'す゛','ぜ': 'せ゛','ぞ': 'そ゛',
    'だ': 'た゛', 'ぢ': 'ち゛','づ': 'つ゛','で': 'て゛','ど': 'と゛',
    'ば': 'は゛', 'び': 'ひ゛','ぶ': 'ふ゛','べ': 'へ゛','ぼ': 'ほ゛',
    'ぱ': 'は゜', 'ぴ': 'ひ゜','ぷ': 'ふ゜','ぺ': 'へ゜','ぽ': 'ほ゜',
    'ガ': 'カ゛', 'ギ': 'キ゛','グ': 'ク゛','ゲ': 'け゛','ゴ': 'コ゛',
    'ザ': 'サ゛', 'ジ': 'シ゛','ズ': 'ス゛','ゼ': 'セ゛','ゾ': 'ソ゛',
    'ダ': 'タ゛', 'ヂ': 'チ゛','ヅ': 'ツ゛','デ': 'テ゛','ド': 'ト゛',
    'バ': 'ハ゛', 'ビ': 'ヒ゛','ブ': 'フ゛','ベ': 'ヘ゛','ボ': 'ホ゛',
    'パ': 'ハ゜', 'ピ': 'ヒ゜','プ': 'フ゜','ペ': 'ヘ゜','ポ': 'ホ゜',
    'ぁ': '…', 'ぃ': '➡️','ぅ': '★','ぇ': '⧗','ぉ': '⬆️',
    'ァ': 'ˇ', 'ィ': '∧','ゥ': '❎','ェ': '▤','ォ': '▥',
    'ゔ': 'う゛', 'ヴ': 'ウ゛','ぅ゙': 'ぅ゛','ゥ゙': 'ゥ゛',
    'ー': '-', '-': '-', '~': '~', 
  }
  var result = ''
  for (var i = 0; i < text.length; i++) {
    result += kanamap[text.charAt(i)] || text.charAt(i);
  }
  return result;
}

Notes

chrcode 144-153 are used as discarded kana.(ぁぃぅぇぉァィゥェォ)

It is quite difficult to maintain hiragana visibility at small sizes. As a desperate measure, I tilted the characters and crammed them into that area.
Katamuki = tilt

P#130144 2023-05-25 14:08 ( Edited 2023-08-28 08:30)

:: Unfold ::

Cart #knutil_msplit-1 | 2023-05-22 | Code ▽ | Embed ▽ | No License
2

Feature Overview

MSPLIT() Converts a string into a table by splitting it with multiple delimiters.

  • The default delimiter is " " for ease of data entry and readability(according to one's own preference).
  • the default delimiters and numeric conversion flags should be modified according to your project.
  • This function consumes 36 Token.
-- Split a pair of data and further split it into colors and names.

local value=msplit(
     '10-yellow 11-green 8-red 12-blue'
     ,' ','-'
    )

for i,v in pairs(value) do

    local col,name=unpack(v)
    ?name,i*32-24,48,col

end

If you want to check the type at once, consider using a DMP().
This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#130014 2023-05-22 08:40 ( Edited 2023-05-22 08:41)

:: Unfold ::

Cart #knutil_tohex-1 | 2023-05-20 | Code ▽ | Embed ▽ | No License
2

Feature Overview

TOHEX() Converts to a hexadecimal string filled with zeros.

  • If the number of digits is not specified, specify 0.
  • The maximum number of digits specified is 4.
  • This function consumes 40 Token.
?tohex(32)   -- 20
?tohex(32,3) -- 020

?tohex('0x32',1)   -- 32

This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#129956 2023-05-20 10:56 ( Edited 2023-05-20 11:10)

:: Unfold ::

Cart #knutil_tonorm-0 | 2023-05-19 | Code ▽ | Embed ▽ | No License
1

Feature Overview

TONORM() normalize argument values (strings) to the correct type.

  • Mainly converts from strings to values of the correct type.
    • Especially used to initialize multiple values from a long string, see HTBL().
  • Hexadecimal numbers are converted to decimal numbers.
  • This function consumes 28 Token.
?tonorm('true') -- true (The type is 'boolean')
?tonorm('nil') -- [nil] (The type is 'nil')

This function is included in the KNUTIL library.
If you want to check the type at once, consider using a DMP().

release note


v0.1

  • first release
P#129901 2023-05-19 08:17 ( Edited 2023-05-19 09:44)

:: Unfold ::

Cart #knutil_exrect-0 | 2023-04-24 | Code ▽ | Embed ▽ | No License
1

Feature Overview

EXRECT() creates a rectangle object with extended functionality.

  • The created rectangle object can be drawn and its inclusions and overlaps can be checked.
  • Drawing and update functions return their own objects, so they can be written in succession.
  • This function consumes 388 Token.(include comb() and cat() functions)
r = exrect('10 80 16 24') -- generate a rectangle object from a string. x:10, y:10, width:16, height:24
r.rf(6).rs(7) -- draw "r" with rectfill, and then draw it again with rect.

?r.con(13,80)  -- true
?r.con(9,80)  -- false

?r.con(exrect'12 82 8 8')  -- true
?r.con(exrect'9 82 8 8')  -- false

?r.hov(exrect'12 82 8 8')  -- true
?r.hov(exrect'9 82 8 8')  -- true

--Check the code for further applications!

This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#128952 2023-04-24 10:24

:: Unfold ::

In the code editor's search function, if you enter a search word and then double-click on the text, the search word is reset and you cannot use ctrl + G( or ctrl + H) to search for the next word.

P#127653 2023-03-27 10:05 ( Edited 2023-03-27 10:05)

:: Unfold ::

Cart #p8ooccapture-7 | 2023-07-11 | Code ▽ | Embed ▽ | No License
6

Feature Overview

Capture the string for "One-off character" used in P8SCII from the sprite sheet and copy it to the clipboard.

  • Simply print() the copied string to draw an image like spr().
  • No decoder implementation is required.

!! Uses mouse control which does not work with BBS.

Please download and use it. !!

Type on your console

> load #p8ooccapture

Note: Turn on "PUNY FONT MODE" when pasting into the code.
Depending on the character, sound may be made or the display of raw characters may be corrupted.

I have made one in the past with fillp and rectfill for equivalent purposes(FILLPatDraw), and I believe P8OOCPrint will be lighter and faster performing than this.

Control method

mouse moving:
    move cursor

ctrl/cmd key + mouse moving:
    grid movement

left button drag:
    capture size change

ctrl/cmd + left button drag:
    change multiple selections

right button drag (space-bar):
    scroll screen

ctrl/cmd + right button drag (space-bar):
    screen grid scrolling

mouse wheel:
    zoom in/out of screen

ctrl/cmd + c key
    one-off character captured in full color

ctrl/cmd + shift + c key
    capture one-off character in silhouette

enter
    open the pause menu
    - copy code: the sample code for drawing is in this.
    - custom font: encoding using custom fonts. custom font setup code is also copied to clipboard when captured.

**when printing a capture, it is recommended to specify coordinates.**

Printed samples of One-off characters

--** Add [\^.] to the copied CHARACTER and print(). **--

?"\^.\0\14\14>>>\0\0" -- Tilted Heart
?"\^.\0\0「\0B<\0\0" -- Smiling mouth
?"\^.ヲュ◜◝◝○?゜" -- Tilted crystal

Update history


v0.6.0

  • fix: changed some escape characters to one-character notation.(more compression)
  • fix: avoided a bug that caused an error if the coordinates of the click start were not taken.

v0.5.0

  • add: the functionto encode using custom fonts. set in the pause menu.
  • add: [ui] display horizontal and vertical numbers for multiple selections.
  • fix: avoided notation of adjacent control characters and numbers.

v0.4.0

  • add: support for repeating instructions "\*x" for duplicate patterns.
  • add: delete whitespace before line break.
  • add: [ui]color-coded sprite sheet range.
  • add: [ui]compressor initialization with message.
  • add: [ui]displays a guide cursor for range selection and multiple selections.
  • add: [ui]adjust the scroll range of the sprite sheet.
  • fix: [ui]adjustment of range and multiple selections.
  • fix: [ui]hide ui during selection operation.
  • fix: changed position display to 0-padding.
  • del: eliminated compression of inverted fills.

v0.3.0

  • add: support for single-character expressions by matching against default font patterns.
  • fix: substitution to split character codes 0~15 and numeric characters.
  • add: the most frequent patterns are selected as shortened characters. (default font supported)
  • add: instruction to turn off P8SCII's border background.

v0.2.0

  • add: supports grid movement.
  • add: sprite capture size change.
  • add: captures of multiple sprites at once.
  • add: support for drag-and-drop import of sprites.
  • add: copy of code for simple drawing to menu.
  • fix: conversion method of control codes "\0 \14 \15".
  • fix: add double quotation marks to the capture code

v0.1.0

  • first release.
P#127257 2023-03-17 06:50 ( Edited 2023-07-11 05:16)

:: Unfold ::

Cart #strdsum-0 | 2023-02-02 | Code ▽ | Embed ▽ | No License
4

Feature Overview

STRDSUM() sums two numerable strings.

  • The number of digits it can handle exceeds the 32-bit limit. (Probably as long as the system will allow.)
  • Match the string length to the longer of the two arguments.
  • Negative values and values after the decimal point cannot be handled.(Insert a period in the output result.)
  • This function consumes 63 Token.

This code may cause errors in versions prior to 0.2.5c.

?strdsum('32768','32768') -- 65536

?strdsum('500','000500') -- 001000

?strdsum('900109','123456') -- 1023565
P#125166 2023-02-02 12:58 ( Edited 2023-05-13 11:59)

:: Unfold ::

Hello @zep

One of my game players reported this.
It seems that Pico8 games downloaded from Steam sometimes fail to start when a controller is connected.

Target game in which the bug occurred.

https://store.steampowered.com/app/1448220/KONSAIRI/

Running environment

  • Apple silicon Mac.
  • Gamepad "Sony PlayStation® DualSense™ Wireless Controller" ----STORE PAGE.
  • Using Steam's controller linkage function (Bluetooth).
  • Exported cart pico8 version 0.2.2c (also occurs in 0.2.5e)

Crash report

https://docs.google.com/document/d/1u615ThHWhl_YEK8agfgb5EENnyzfXKkhnk_ach4XDgA/edit?usp=sharing

Thank you for your cooperation.

P#123735 2023-01-09 08:37

:: Unfold ::

In the screenshot, the pause menu does not appear.

But in the case of GIF output, the pause menu seems to appear.
(version 0.2.5c)

P#59536 2022-12-09 12:06 ( Edited 2022-12-09 12:08)

:: Unfold ::

Cart #knutil_bpack-0 | 2022-12-01 | Code ▽ | Embed ▽ | No License

Feature Overview

BPACK() pack the value of the bit specification with bit width.

  • By packs in the direction of low bits when multiple bit values are specified.
  • By setting [number s] to a negative value, bit pack can be started from the decimal point.
  • If there are fewer bit-width elements relative to the value to be packed, the bit-width elements are rotated.
  • This function consumes 37 Token.
v=bpack({8,4},0,0xff,0xb)
?tostr(v,1) -- 0x00ff.b000 (bit-left-shift:0)

v=bpack({8,4},8,0xff,0xb)
?tostr(v,1) -- 0xffb0.0000 (bit-left-shift:8)

This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#59572 2022-12-01 13:18 ( Edited 2022-12-02 15:17)

:: Unfold ::

Cart #knutil_bunpack-2 | 2022-11-30 | Code ▽ | Embed ▽ | No License
1

Feature Overview

BUNPACK() slice the value with bit width.

  • By specifying the argument after [number w], a value of up to 32 bits can be sliced.
  • By setting [number s] to a negative value, bit slice can be started from the decimal point.
  • This function consumes 30 Token.
a,b=bunpack(0xf8,4,4,4) -- Value, First bit-shift, bit-width, ...[bit-width]
?a -- 15 (0xf)
?b -- 8 (0x8)

This function is included in the KNUTIL library.

release note


v0.1

  • first release
P#121616 2022-11-30 12:12 ( Edited 2022-12-02 15:17)

:: Unfold ::

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

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

View Older Posts
Follow Lexaloffle:          
Generated 2023-10-03 04:57:46 | 0.118s | Q:85