moved built-in Lua to ag.lua, converting to C with xxd
git-svn-id: svn://anubis/anaglym/trunk@232 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
8eead374af
commit
fd33b69d78
6
Makefile
6
Makefile
@ -7,7 +7,8 @@ WINDOWS := 1
|
||||
endif
|
||||
|
||||
TARGET := anaglym
|
||||
COBJS := $(patsubst %.c,%.o,$(wildcard *.c))
|
||||
SOURCES := $(wildcard *.c) ag_lua.c
|
||||
COBJS := $(patsubst %.c,%.o,$(SOURCES))
|
||||
CXXOBJS := $(subst sdl_keymap.o,,$(patsubst %.cc,%.o,$(wildcard *.cc))) sdl_keymap.o
|
||||
OBJS := $(COBJS) $(CXXOBJS)
|
||||
CDEPS := $(COBJS:.o=.dep)
|
||||
@ -57,6 +58,9 @@ all: $(TARGET)
|
||||
$(TARGET): $(OBJS) wfobj/WFObj.o OdeWorld/OdeWorld.o TextureCache/TextureCache.o
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
ag_lua.c: ag.lua
|
||||
xxd -i $< > $@
|
||||
|
||||
.PHONY: wfobj/WFObj.o
|
||||
wfobj/WFObj.o:
|
||||
$(MAKE) -C wfobj
|
||||
|
53
ag.cc
53
ag.cc
@ -1,5 +1,6 @@
|
||||
|
||||
#include "ag.h"
|
||||
#include "ag_lua.h"
|
||||
#include "anaglym.h"
|
||||
#include "Engine.h"
|
||||
#include "Video.h"
|
||||
@ -76,57 +77,9 @@ namespace ag
|
||||
};
|
||||
luaL_register(L, "ag", functions);
|
||||
|
||||
luaL_loadstring(L,
|
||||
"next = ag.next\n"
|
||||
ag_lua[ag_lua_len - 1] = '\0';
|
||||
luaL_loadstring(L, (const char *) ag_lua);
|
||||
|
||||
"type = ag.type\n"
|
||||
|
||||
"pairs = function(table)\n"
|
||||
" return next, table, nil\n"
|
||||
"end\n"
|
||||
|
||||
"ipairs = function(table)\n"
|
||||
" local iter_func = function(t, i)\n"
|
||||
" i = i + 1\n"
|
||||
" if t[i] == nil then\n"
|
||||
" return nil\n"
|
||||
" else\n"
|
||||
" return i, t[i]\n"
|
||||
" end\n"
|
||||
" end\n"
|
||||
" return iter_func, table, 0\n"
|
||||
"end\n"
|
||||
|
||||
"ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)\n"
|
||||
" local o1 = obj1\n"
|
||||
" local o2 = obj2\n"
|
||||
" local num_axes = 1\n"
|
||||
" if (type(obj1) == \"number\") then\n"
|
||||
" if (obj1 == 0) then\n"
|
||||
" o1 = { id = 0 }\n"
|
||||
" end\n"
|
||||
" end\n"
|
||||
" if (type(obj2) == \"number\") then\n"
|
||||
" if (obj2 == 0) then\n"
|
||||
" o2 = { id = 0 }\n"
|
||||
" end\n"
|
||||
" end\n"
|
||||
" local num_axes = 0\n"
|
||||
" if (axis0 ~= nil) then\n"
|
||||
" setAMotorAxis(0, axis0)\n"
|
||||
" num_axes = 1\n"
|
||||
" if (axis1 ~= nil) then\n"
|
||||
" setAMotorAxis(1, axis1)\n"
|
||||
" num_axes = 1\n"
|
||||
" if (axis2 ~= nil) then\n"
|
||||
" setAMotorAxis(2, axis2)\n"
|
||||
" num_axes = 2\n"
|
||||
" end\n"
|
||||
" end\n"
|
||||
" end\n"
|
||||
" ag.setAMotorNumAxes(num_axes)\n"
|
||||
"end\n"
|
||||
);
|
||||
lua_pcall(L, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
52
ag.lua
Normal file
52
ag.lua
Normal file
@ -0,0 +1,52 @@
|
||||
next = ag.next
|
||||
|
||||
type = ag.type
|
||||
|
||||
pairs = function(table)
|
||||
return next, table, nil
|
||||
end
|
||||
|
||||
ipairs = function(table)
|
||||
local iter_func = function(t, i)
|
||||
i = i + 1
|
||||
if t[i] == nil then
|
||||
return nil
|
||||
else
|
||||
return i, t[i]
|
||||
end
|
||||
end
|
||||
return iter_func, table, 0
|
||||
end
|
||||
|
||||
ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)
|
||||
local function setAMotorAxis(amotor, anum, axis)
|
||||
end
|
||||
local o1 = obj1
|
||||
local o2 = obj2
|
||||
local num_axes = 1
|
||||
if (type(obj1) == "number") then
|
||||
if (obj1 == 0) then
|
||||
o1 = { id = 0 }
|
||||
end
|
||||
end
|
||||
if (type(obj2) == "number") then
|
||||
if (obj2 == 0) then
|
||||
o2 = { id = 0 }
|
||||
end
|
||||
end
|
||||
local num_axes = 0
|
||||
if (axis0 ~= nil) then
|
||||
setAMotorAxis(0, axis0)
|
||||
num_axes = 1
|
||||
if (axis1 ~= nil) then
|
||||
setAMotorAxis(1, axis1)
|
||||
num_axes = 1
|
||||
if (axis2 ~= nil) then
|
||||
setAMotorAxis(2, axis2)
|
||||
num_axes = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
ag.setAMotorNumAxes(num_axes)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user