Log In  

@Shadowblitz16

Follow
Follow

can someone tell me why I am running out of memory?

Cart [#jajefutayu-1#] | Code | 2019-07-18 | No License | Embed

@Catatafish I completely changed the question I realized i do not have an infinite loop. I just assumed since I was running out of memory.

this line seems to be doing it and idk why..

o:procx()
P#65895 2019-07-16 23:07 ( Edited 2019-07-18 20:08)

can someone tell me why this throws the error "attempt to call global vec a table value"?
vec clearly has its metatable set with a call metaevent

vec=
{   
    x=0,
    y=0,
    mag=function(o) return sqrt (o.x^2+o.y^2) end,
 ang=function(o) return atan2(o.x,  o.y  ) end,
 nrm=function(o) return vec(o:ang()/360) end,  
}
vecmeta=
{
     __call=function(o,x,y)
      o  =o or {} 
            o.x=y and x or cos((x+90)/360)
            o.y=y and y or-sin((x+90)/360)  
            return setmetatable(o,vec)
        end,
        __eq=function(a,b)
            a=type(a) == "number" and vec(a,a) or a
            b=type(b) == "number" and vec(b,b) or b
            return (a.x==b.x and a.y==b.y)
        end,
        __add=function(a,b)
            a=type(a) == "number" and vec(a,a) or a
            b=type(b) == "number" and vec(b,b) or b
            return vec(a.x+b.x,a.y+b.y)
        end,
        __sub=function(a,b)
            a=type(a) == "number" and vec(a,a) or a
            b=type(b) == "number" and vec(b,b) or b
            return vec(a.x-b.x,a.y-b.y)
        end,
        __mul=function(a,b)
            a=type(a) == "number" and vec(a,a) or a
            b=type(b) == "number" and vec(b,b) or b
            return vec(a.x*b.x,a.y*b.y)
        end,
        __div=function(a,b)
    a=type(a) == "number" and vec(a,a) or a
            b=type(b) == "number" and vec(b,b) or b
            return vec(a.x/b.x,a.y/b.y)
        end,
}
setmetatable(vec, vecmeta)

local test =
{
    pos=vec(0,0),
    vel=vec(0,0),
}
P#65879 2019-07-16 05:14

can someone tell me why I am getting nil when printing out the stars px and py values?

local stars={}
for i=0, 16 do add(stars,{x=rnd(128),y=rnd(128),px=x,py=y,c=7}) end --px and py are equal to x and y

drwmenu=function()
    if btn(2) then menuind-=1 end
    if btn(3) then menuind+=1 end
    menuind=mid(0,4)

    for v in all(stars) do
    print(v.px) --prints nil 
    print(v.py) --prints nil
        line(v.x,v.y,v.px,v.py,v.c)
        --line(v.x,v.y-128,v.px,v.py,v.c)
        --v.py=v.y

        --v.y+=8
        if v.y > 127 then v.y-=128 end
    end
    if (time()-last > 1) then
        rectfill(0,112,127,120,1)
        print("press start!",0,114,7)
        if (time()-last > 2) then last=time() end
    end
end
P#65802 2019-07-13 05:25

does yield() work outside of coroutines and inside functions?

I feel coroutines are a pain to setup and update when it would just be easier to call yield inside a function
not to mention the tokens required to setup coroutines and call/update them

function wait(t)
  for x=1,t do yield() end
end

function test()
 wait(2)
 print("test")
 wait(2)
end

function _update()
 test()
end
P#65801 2019-07-13 03:08

is there a build in function that rotates a drawn tile by 90 degrees for the 4 possible values of 0,1,2 and 3?

P#65754 2019-07-10 23:10

I came up with several functions that I think would go good in pico8 and would reduce file size for larger games

--math
function ldirx(l,d)          --stands for lengthdirx accepts degrees and saves 2 chars per call
function ldiry(l,d)          --stands for lengthdiry accepts degrees and saves 2 chars per call
function plen(x0,y0,x1,y1)   --stands for pointlen and saves 16 chars per call
function pdir(x0,y0,x1,y1)   --stands for pointdir and saves 2 char per call
function wrap(x, y, z)       --stands for wrap and saves 66 chars per call
function range(v,a1,a2,b1,b2)--stands for rerange and saves 31 chars

--vectors                        
function vec(x,y)    --stands for vector and saves 16 chars per call
function vgetl(v)    --stands for vector get length and saves 26 chars per call if using plen
function vsetl(v,x,y)--stands for vector set length and accepts a vector or a len and deg and saves 134 chars
function vaddl(v,x,y)--stands for vector  += length and accepts a vector or a len and deg and saves 134 chars
function vsubl(v,x,y)--stands for vector  -= length and accepts a vector or a len and deg and saves 134 chars
function vmull(v,x,y)--stands for vector  *= length and accepts a vector or a len and deg and saves 134 chars
function vdivl(v,x,y)--stands for vector  /= length and accepts a vector or a len and deg and saves 134 chars
function vgetd(v)    --stands for vector get dir and accepts a deg and saves 24 chars
function vsetr(v,r)  --stands for vector set dir and accepts a deg and saves 43 chars
function vaddr(v,r)  --stands for vector  += dir and accepts a deg and saves 43 chars
function vsubr(v,r)  --stands for vector  -= dir and accepts a deg and saves 43 chars
function vmulr(v,r)  --stands for vector  *= dir and accepts a deg and saves 43 chars
function vdivr(v,r)  --stands for vector  /= dir and accepts a deg and saves 43 chars

--tables
function copy(v) --stands for copy and saves 152 chars

some notes..

  • while ldirx, ldiry, plen and pdir wouldn't save alot of space they would be easier to understand and would definitly be used by newer programmers
  • the wrap function would wrap numbers around a min and max value and would be useful besides just saving space

  • range is another useful function that would take 2 ranges of numbers and return a converted value between those ranges

  • vectors while I only posted 2d versions could actually be made to work with 3d as well by supplying a additional z, vector, length and direction.

  • copy would just return a deep copy of the table u give it and would make oop easier and take less space up in the cart
P#55218 2018-08-15 22:36 ( Edited 2018-08-18 02:52)

is there a plan to add built in pico8 multiplayer using synced inputs?

basically it would be handled in pico8 rather than the cart.

it would allow players to connect to each other via ip or game uid and official lexaloffle connecting servers through the pause menu.

this might be the easiest way to build a multiplayer game since there would be no packets being sent besides the hard coded inputs.

networked inputs would be accessible the same way normal inputs are with btn(btn, player).

this would also make multiplayer games have not just networked players but local ones as well.
players count would be limited to the number of inputs pico8 has.

P#54986 2018-08-11 23:21 ( Edited 2018-08-12 18:55)

does anybody have a good rspr(n, x, y, w, h, r, ox, oy, flipx, flipy) function to draw rotated sprites?
I need this to make my 4 player spaceship battle game.

P#54942 2018-08-10 21:40 ( Edited 2018-08-11 01:40)

ok so I think I get how people like pico 8 for its limitations. but will pico 8 ever support 4 players simultaneously?

this would be good for things like raspberry pi where 4 players can sit on a couch and play small 4 player games together.
what do you guys think?
I know older hardware only supported up to 2 players but I think this would be a good idea for the compactness of pico8.

P#48987 2018-02-04 20:54 ( Edited 2018-02-05 18:42)

I was just wondering everybody's opinion on the limitations of pico8?

right now there isn't really much we can do with it besides make very simple 1 level games.
pico8 could do much better if code limitations weren't so harsh.

also it seems people smash all there code together to preserve tokens which is not good
for example..
this takes up more space

local var = 0
      var = var + 1

then this

local var=0 var=var+1

which makes no sense

if code limitations were removed and cart loading time was reduced significantly
then pico8 could make much larger games while still saving to a small cart size.

what would even be better if pico 8 carts were separated into 2 parts

  • the compiled game
  • and the dev files

so what do you guys think?

keeping the games small maybe be fun but you can only do so much with it especially with the severe limitations of pico8.

P#48908 2018-02-02 20:59 ( Edited 2018-02-17 20:56)

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-23 09:31 | 0.074s | 4194k | Q:40