Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Lua api Sticky Locked

A topic by Oblerion Studio created Dec 30, 2023 Views: 151
This topic is locked
Viewing posts 1 to 1
Developer (20 edits)

a1.8.2 Gamepad

if btn(id) then
 -- gamepad button isdown
end
if btnp(id) then
 -- gamepad button ispressed
end

id map:

a1.8 Music loading

music_loaddir("dir") -- load .wav .mp3 .ogg in ./dir/*
music_playsound("sound") -- play sound.wav
music_playmusic("music") -- play music.mp3/.ogg
music_pausemusic() -- pause currant music play
music_stopmusic() -- stop currant music play

a1.7 Interverse

Run an other game, read extern save.

Run game

run("projet.egba") -- work with .lua 

Read extern save

-- if target is projet.sav
local numb = rsave_numb_ext("projet",id)
local nstring = rsave_string_ext("projet",id)
local nbool = rsave_bool_ext("projet",id)

Entry point

Create projet.entry for run (projet.lua / projet.egba) at start.

a1.6

Save-state (.sav file)

This is static data, it keep value when quit.

Write save

wsave_numb(id,100)
-- id 0 → 50
wsave_string(id,"name")
-- id 0 → 50, string 35 char
wsave_bool(id,true)
-- id 0 → 100

Read save

local i_num = rsave_numb(id)
-- id 0 → 50
local i_string = rsave_string(id)
-- id 0 → 50
local i_bool = rsave_bool(id)
-- id 0 → 100

a1.5

Main

loop function

function EGBA()
-- your code run 60/seconds
end

log

trace("hi")
-- print hi in console (only string)
local v=2 print("value :",v)
-- lua print function can be used to view variable value in console

palette swap

pal(2)
-- id 0 -> 4, change curant palette 
-- for all function after with id color    

Graphics

clear screen

cls(0)
-- clear screen with id color 0 

print text

text("hello world",23,23,0,16)
-- x 23, y 23, id color 0,font size 16

draw rectangle

rect(23,23,50,50,2)
-- draw fill rectangle in x 23, y 23, width 50, height 50, id color 2
rectb(23,23,50,50,2)
-- draw line rectangle in x 23, y 23, width 50, height 50, id color 2 

draw pixel

pix(10,10,2)
-- draw pixel in x 10,y 10, id color 2

draw sprite

spr(1,23,23,2)
-- draw sprite id 1,x 23,y 23,scale 2

Input

keyboard

if btn(0) then
-- if key down is down
elseif btn(1) then
-- if key up is down
end
if btnp(2) then
-- if key left is pressed 
elseif btnp(3) then
-- if key right is pressed
end
-- id 0 : down, 1 : up, 2 : left, 3 : right, 4 : x, 5 : c
-- btn -> btn is down
-- btnp -> btn is pressed

mouse

local x,y,btnl,btnm,btnr = mouse()
-- x = x mouse
-- y = y mouse
-- btnl = true/false mouse left button
-- btnm = true/false mouse mid button
-- btnr = true/false mouse right button