WIP (transfération d'un ordi à un autre)
This commit is contained in:
parent
efd52dae7d
commit
081ceeb70e
8 changed files with 36 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
|||
|
||||
OUTNAME = mtycoon
|
||||
|
||||
CFLAGS = -O0 -Wall -Wextra -g -I./raylib/include -I./lua/include -pipe
|
||||
CFLAGS = -O2 -Wall -Wextra -g -I./raylib/include -I./lua/include -pipe
|
||||
|
||||
CC = gcc
|
||||
|
||||
|
|
BIN
map/converter
BIN
map/converter
Binary file not shown.
|
@ -22,3 +22,8 @@ end
|
|||
function on_frame(game)
|
||||
|
||||
end
|
||||
|
||||
function on_load(game, map)
|
||||
mtprint("loaded map :")
|
||||
mtprint(map)
|
||||
end
|
||||
|
|
|
@ -58,8 +58,6 @@ int init_game(Game *game){
|
|||
return 1;
|
||||
}
|
||||
|
||||
load_map(game, 0);
|
||||
|
||||
int c_worker = 0;
|
||||
|
||||
for(int k = 0; k < 16; k++){
|
||||
|
|
|
@ -258,6 +258,29 @@ void lua_onframe(Game *game){
|
|||
lua_callloop(game, "on_frame");
|
||||
}
|
||||
|
||||
void lua_onmapload(Game *game, int map){
|
||||
gl_game = game;
|
||||
for(int i = 0; i < lstate_n; i++){
|
||||
lua_State *L = lstates[i];
|
||||
lua_mkgame(L, game);
|
||||
if(lua_getglobal(L, "on_load") == LUA_TNIL){
|
||||
lua_pop(L, 2);
|
||||
continue;
|
||||
}
|
||||
lua_pushvalue(L, -2);
|
||||
lua_pushinteger(L, map);
|
||||
int ret = lua_pcall(L, 2, 0, 0);
|
||||
if(ret)
|
||||
puts(lua_tostring(L, -1));
|
||||
else{
|
||||
lua_pushliteral(L, "cash");
|
||||
lua_gettable(L, -2);
|
||||
if(lua_isinteger(L, -1))
|
||||
game->cash = lua_tointeger(L, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lua_mt_init(lua_State *L){
|
||||
for(int i = 0; i < sizeof(exported_funcs)/sizeof(*exported_funcs); i++)
|
||||
lua_register(L, exported_funcs[i].name, exported_funcs[i].fn);
|
||||
|
|
|
@ -7,6 +7,8 @@ void lua_ontick(Game *game);
|
|||
|
||||
void lua_onframe(Game *game);
|
||||
|
||||
void lua_onmapload(Game *game, int map);
|
||||
|
||||
void script_init();
|
||||
|
||||
void script_clean();
|
||||
|
|
|
@ -30,6 +30,7 @@ int init(Game *game){
|
|||
err |= init_game(game);
|
||||
init_ui();
|
||||
script_init(game);
|
||||
load_map(game, 0);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "draw.h"
|
||||
#include "lua_inter.h"
|
||||
|
||||
extern MapCollec mapcollec;
|
||||
|
||||
|
@ -39,6 +40,9 @@ int load_map(Game *game, int mapn){
|
|||
return 1;
|
||||
if(generate_coll(game, mapn))
|
||||
return 1;
|
||||
|
||||
lua_onmapload(game, mapn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue