Lua for TIC80: Difference between revisions

From XPUB & Lens-Based wiki
Line 1: Line 1:
== tables ==
== tables ==
[[File:tic80-table.png]]


<source lang="lua">
<source lang="lua">
Line 13: Line 11:
  end
  end
end
end
</source>
[[File:tic80-table.png]]
<source lang="lua">
PLANE={
START_FUEL=2000,
MAX_FUEL=4000,
FUEL_INC=1000,
FUEL_BAR_W=50
}
</source>
</source>



Revision as of 21:35, 31 January 2021

tables

squares={1,4,9,16,25,36,49,64,81}

function TIC()
 cls(0)
 for i=1,#squares do
  print(i,i*16,0)
  print(squares[i],i*16,10)
 end
end

Tic80-table.png

PLANE={
 START_FUEL=2000,
 MAX_FUEL=4000,
 FUEL_INC=1000,
 FUEL_BAR_W=50
}

if

See: https://www.lua.org/pil/4.3.1.html

if btn(0) then
 t=t+1
elseif btn(1) then
 t=t-1
end

j94Lj.png

for

Tic80-forloop.png

See: https://www.lua.org/pil/4.3.4.html

function TIC()
 cls(0)
 
 for i=1,100,2 do
  rect(0,0,i,i,i%16)
 end

end

function

break, return

https://www.lua.org/pil/4.4.html