3 Commits

Author SHA1 Message Date
9db783b3ac - Exemple de objectes en lua, crec 2023-11-28 13:16:57 +01:00
2dcbdfa975 - Activades les llibreries estandar de lua 2023-11-28 13:16:53 +01:00
709a74a76a No se 2023-09-07 11:45:44 +02:00
3 changed files with 29 additions and 14 deletions

View File

@@ -1,20 +0,0 @@
function init()
mode(0)
cls()
play("o4v5l1crcl4dcferl1crcl4dcgfr")
end
function update()
cls()
locate(0,0)
if mousebutton(1) then
print("Has pulsat el boto esquerre")
elseif mousebutton(2) then
print("Has pulsat el boto del mig")
elseif mousebutton(3) then
print("Has pulsat el boto dret")
else
print("No has pulsat cap boto")
end
end

34
game.lua Normal file
View File

@@ -0,0 +1,34 @@
Persona = {
name = "---",
}
function Persona:SayName()
print(self.name .. " ")
end
function Persona:new(obj)
obj = obj or {}
setmetatable(obj, self)
--self.__index = self
return obj
end
function init()
mode(0)
cls()
Persona.__index=Persona
persones={}
persones[1] = Persona:new({name="Persona1"})
persones[2] = Persona:new({name="Persona2"})
persones[3] = Persona:new({name="Persona3"})
persones[4] = Persona:new({name="Persona4"})
for i,v in ipairs(persones) do
v:SayName()
end
end
function update()
end

View File

@@ -422,6 +422,7 @@ const char boot[] = "function init()mode(1)cls()play('o5l0v5cegv4cegv3cegv2cegv1
void lua_init(const char* filename, const bool start_playing) { void lua_init(const char* filename, const bool start_playing) {
if (lua_state != STATE_STOPPED) lua_quit(); if (lua_state != STATE_STOPPED) lua_quit();
L = luaL_newstate(); L = luaL_newstate();
luaL_openlibs(L);
//init_exists = update_exists = false; //init_exists = update_exists = false;
bool file_loaded = true; bool file_loaded = true;

View File

@@ -4,6 +4,6 @@
//extern "C" { //extern "C" {
#include "lua.h" #include "lua.h"
//#include "lualib.h" #include "lualib.h"
#include "lauxlib.h" #include "lauxlib.h"
//} //}