Compare commits

2 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
3 changed files with 29 additions and 2 deletions

View File

@@ -1,7 +1,33 @@
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()
print("HOLA MUNDO!")
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()

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) {
if (lua_state != STATE_STOPPED) lua_quit();
L = luaL_newstate();
luaL_openlibs(L);
//init_exists = update_exists = false;
bool file_loaded = true;

View File

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