Log In  


Cart #pico9-26 | 2025-10-10 | Code ▽ | Embed ▽ | No License
5

This is a "base" cart with extra features (wow!)
Would appreciate notification of any bugs

How to set up cart:

  1. delete all demo values (functions included)
  2. delete the sections in the loop functions which say "delete this"
  3. if you are using cartdata, set using_cartdata to true, and set save_menuitem to the string that you want to appear in the menu when saving
  4. if you want to use more than 64 cartdata values, set saverange_start to the first memory address in the range subtracted by 0x8000, set saveids to how many more save groups of 64 cartdata values you need, and using_cartdata_extra to true
  5. set game_id to your cartridge id. this will be used in cartdata functions and reloading for calibrating and recalibrating save values
  6. set the g_init, g_update and g_draw functions to your own personal loops

optionals
there is a table called genopmt. this is an automatically prepared metatable
there is also a collection of all visible characters through characters 1-15 in the first few lines of the main _init() tab

FUNCTIONS:

-- DRAWING FUNCTIONS --

polygon(col,centx,centy,[...])

[...]
. given positions

draws a polygon from the given positions e.g. polygon(11,64,64,{-4,-4},{4,-4},{4,4},{-4,4}) (draws a square)

spinpol3d(col,centx,centy,progression,[...])

note: very uncontrollable. this function was found from a glitch

[...]
. given positions

draws a selection of lines which seem to resemble a 3d shape. it is currently unknown how to use this function in any purposeful way, though if anyone knows how to use it, an explanation as of how to use it would be greatly appreciated

tblpol(col,centx,centy,positions)

draws a polygon from a table of positions (positions parameter) e.g. polygon(11,64,64,{{-4,-4},{4,-4},{4,4},{-4,4}})

regpol(points,centx,centy,rad,progression,col)

draws a regular polygon at the given coordinates, and turns based on how large the progression value is

rotspr([n],x,y,w,h,flipx,flipy)

draws a sprite rotated 90 degrees counter-clockwise

specspr(sprmapx,sprmapy,drawx,drawy,w,h,flipx,flipy)

draws a sprite with specific given coordinates on the sprite map

approxpoint(perimcol,connectcol,perimpointcol,centrad,perimpointrad,[...])

[...]
. given positions

return-value
. average point coordinates (in table value)

draws a polygon with each point along the perimeter of the polygon connecting to the average position of all given positions e.g. approxpoint(11,9,10,2,2,{60,60},{68,60},{68,68},{60,68})

dapproxpoint([...])

[...]
. given positions

return-value
. average point coordinates (in table value)

runs approxpoint with automatically set colours and radiuses.

loadimage(p,w,h,x,y)

draws an image of all of the hexadecimal values of colors in p. add "-" to p to skip that pixel

squarepattern(p,x,y,c)

generates an 8x8 texture of the desired color from string p

rndp()

runs fillp with a random pattern

-- PRINTING FUNCTIONS --

cprint(txt,centx,y,c)

prints the text given at the centre of the "centx" parameter

fprint(txt,x,y,c,outc,mlayer)

outc
. color of layer

mlayer
. thickness of layer

prints the text given with a layer of pixels around the text

fcprint(txt,centx,y,c,outc,mlayer)

runs fprint at the centre of the "centx" parameter

rightprint(txt,x,y,c)

prints the given text with the end of the text being at the "x" parameter

rightfprint(txt,x,y,c,outc,mlayer)

runs fprint with the end of the text being at the "x" parameter

rep_print(print_type,txts,x,y,c,dist,outc,mlayer)

dist default=6

prints the split text at the y coordinate added by the text index in which is being printed, multiplied by the distance

-- MAP FUNCTIONS --

flag_at(x,y,f,modx,mody)

modx
. function in which to change the "x" parameter by (defaults to return)

mody
. function in which to change the "y" parameter by (defaults to return)

returns if the given map tile has the flag declared in the parameters

tile_at(x,y)

returns mget(x,y)

-- VALUE MODIFICATION FUNCTIONS (MATH, BOOLEANS, STRINGS) --

val_in_env(method,valpath,setvalue)

sets, gets, or runs a table function for the value indexed by _ENV with valpath split by "." (depends on method parameter (also works for metatables)) the value indexed by _ENV with valpath split by "."

hexadecstr(val,len)

returns a string containing the given number in hexadecimal form e.g. hexadecstr(31,3) returns "01f"

strtohexadec(str)

returns a hexadecimal number from the given string

strtobin(str,len)

returns a binary number from the given string

isub(str,i)

returns the letter of the letter index of the given string

opensplit(str,sep,convert_num)

returns the unpacked split table

remove(str,remstr)

returns the given string with no instance of the "remstr" parameter

replace(str,remstr,rplstr)

returns the given string with all instances of remstr replaced with rplstr

indchar(str)

returns a table of all characters in the given string in order

indword(str)

returns a table of all words in the given string in order

indline(str)

returns a table of all lines in the given string in order

wrap_text_intbl(str,width)

returns a table of all lines of the given string wrapped

wrap_text(str,width)

returns wrap_text_tbl concatenated by "\n"

concat(tbl,sep)

returns a string of the entire table given concatenated by the separator parameter

numstr(num,len)

returns the number value in a string with the length given e.g. numstr(39,3) returns "039"

has_double(str)

returns the amount of 8-pixel-wide characters in the given string

centre(x,y,centx,centy)

returns a table of the positions added by the either "cent" parameter for that coordinate, or, if the parameter is nil, 64 e.g. centre(-4,4,50) returns {46,68}

avg([...])

[...]
. number values in average calculation

returns the average of the values given

tabavg(tbl)

returns the average of all of the values in the given table

tabiavg(tbl,index)

returns the average of the index of all of the tables in the given table e.g. tabiavg({{1,2,4},{1,4},{1,5,7},{7,6,4,8}},2) returns average of 2,4,5, and 6

r(val)

returns the value given. useful for conditional values with functions e.g. (boolean and flr or r)(8.5)

fraction(num,denom)

returns the fraction of the numerator divided by the denominator. hardly necessary but just a shortcut i guess

factorial(val)

returns factorial of the value given

round(val,base)

base
. number to round to. defaults to 1

returns the rounded value to the base

recip(val)

returns the reciprocal of the given value. again, hardly necessary, but this is used in all variations of sec(val)

comball(type,[...])

[...]
. given tables of values in operation

returns a table of all tables given changed by the desired operation. operation is decided from the following strings:
"add":addition,"sub":subtraction,"mul":multiplication,"div":division"mod":modulation,
"pow":exponentiation,"concat":concatenation

tan(val)

returns tangent of given value

cot(val)

returns cotangent of given value

sec(val)

returns secant of given value

cosec(val)

returns cosecant of given value

arcsin(val)

returns arcsine of given value

arccos(val)

returns arccosine of given value

arcsec(val)

returns arcsecant of given value

arccsc(val)

returns arccosecant of given value

arccot(val)

returns arccotangent of given value

bool(val,[convert_num])

[convert_num]
. if number in string matters. defaults to false

returns "boolean value" of given value

bflr(val,base)

base defaults to 1. returns lowest multiple of base from given value

bceil(val,base)

base defaults to 1. returns highest multiple of base from given value

exp10(val)

returns 10^val divided by 10

-- TABLE FUNCTIONS --

tblfind(tbl,iname)

returns the number index of the "iname" parameter in the given table

addmetamethod(tblpath,metatable,metamethod)

adds a new metamethod to the metatable of _ENV indexed by tblpath split by "." if metatable[metamethod] isn't equal to nil.

delmetamethod(tblpath,metatable,metamethod)

deletes a metamethod from the metatable of _ENV indexed by tblpath split by "." if metatable[metamethod] isn't equal to nil.

-- CONDITIONAL FUNCTIONS --

switch(val,default,[...])

[...]
. tables for each case

if the given value is equal to the case in the table currently being checked, it will run the function in that table. if the given value is equal to none of the cases in any of the given tables, it will run the default function

bswitch(val,default,[...])

[...]
. tables for each case

runs switch, but automatically breaks when the function in the tables is decided

-- SOUND FUNCTIONS --

playnote(note)

plays the "note" parameter. does not affect actual sfx or music tracks in any way.

-- TYPE FUNCTIONS --

fortype(tbl,detecttype,func)

runs the given function for all values of the given type in the given table.

changetype(valroot,type)

changes the type of the value indexed by the value name at the end of the string of the value directory (location in all tables) in _ENV, with the directory string being split by "." (also works with number indexing)

-- MISC FUNCTIONS --

inmenu()

returns true if is in menu

-- PROTOTYPES --

these are functions which do not work or did not and are currently being worked on. once function is finished, final function name and type of function will be underneath the main documentation for the function.

squashstr(str,width)

returns a multi-line string value with the max amount of length for each line is decided by the width parameter.

COMPLETE FUNCTION: wrap_text(str,width) in value modification functions

Any more features I should add?

5



[Please log in to post a comment]