Log In  


By Lily Kensa

Whether it's useful or not,

Cart #basic_functions-1 | 2022-03-06 | Code ▽ | Embed ▽ | No License


  • ROUND(value)


  • INVCIRCFILL(x,y,r,col)

    inverse circfill. r = radius, col = color.

  • APOKE(a,b)

    change palette from a to b. (colors are 0 ~ 31)

  • AMGET(x,y)

    do mget() but you don't need to "/8" anymore.

  • BMGET(x,y,map)

    will do amget() and check if the map is the one specified.

  • RECT_BMGET(x,y,width,height,map)

    bmget() but it use a hitbox.

  • AFGET(x,y,flag)

    do fget() from a dot's position.

  • RECT_AFGET(x,y,width,height,flag)

    afget() but it use a hitbox.

  • CYCLE(table,speed)

    circulate the values in the table.

P#108125 2022-03-06 06:53 ( Edited 2022-03-06 07:28)

I've never used the map for a game before, but these look like useful functions to have as a template.

What is the reason you use that 'eval' table? If I needed that to happen I'd probably use ternary operations like:

value=value and 1 or 0
value=value!=0 and true or false

...though I realize this first one accepts anything other than false or [nil] as true and the second one accepts any non-zero number as true, kind of like 'truthiness' in python. Whereas, in eval[value], they require specifically true/false for the first one, and in the second case any other number besides zero or 1 returns [nil], which an if statement will interpret as false, making it different from mine.

Is this kind of value-testing used so often in the code when using maps that calling the eval[value] saves tokens in the long run?

edit: I see from your other carts that you use this to interpret button presses as values, but it doesn't seem to save tokens. Looking at your shadow test cart, you use:


which is 43 tokens, but why not use:

yv+=btn"2" and 1 or btn"3" and -1 or 0
xv+=btn"1" and 1 or btn"0" and -1 or 0

which has the same functionality but in 26 tokens.

Is there some other reason you prefer this method?

P#108135 2022-03-06 15:31 ( Edited 2022-03-06 15:49)

Because I didn't know that the way you mentioned would work ;)
I'm not good with algorithm, so it's just the most simple way I could think of.

P#130063 2023-05-23 12:51

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-22 05:45:29 | 0.028s | Q:18