Somewhat working lua console, no element function overrides, no keyboard, mouse or tick events
This commit is contained in:
parent
d604fac18f
commit
ec6d1012b2
18
Makefile
18
Makefile
@ -6,7 +6,7 @@ OBJS := $(patsubst src/%.cpp,build/obj/%.o,$(SOURCES))
|
||||
FOLDERS :=
|
||||
|
||||
CFLAGS := -w -Isrc/ -Idata/
|
||||
OFLAGS := -fkeep-inline-functions -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -msse2
|
||||
OFLAGS := -fkeep-inline-functions
|
||||
|
||||
CPPC := g++
|
||||
CPPC_WIN := g++
|
||||
@ -19,14 +19,14 @@ powder.exe: build/powder.exe
|
||||
powder-release: build/powder-release
|
||||
powder: build/powder
|
||||
|
||||
build/powder-release.exe: CFLAGS += -DWIN32
|
||||
build/powder-release.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -mwindows
|
||||
build/powder-release.exe: CFLAGS += -DWIN32 -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -pipe -msse -msse2 -msse3 -mmmx
|
||||
build/powder-release.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -llua -mwindows
|
||||
build/powder.exe: CFLAGS += -DWIN32 -DWINCONSOLE
|
||||
build/powder.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 #-mwindows
|
||||
build/powder-release: CFLAGS += -DLIN32
|
||||
build/powder-release: LFLAGS := -lSDL -lm -lbz2
|
||||
build/powder.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -llua #-mwindows
|
||||
build/powder-release: CFLAGS += -DLIN32 -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -pipe -msse -msse2 -msse3 -mmmx
|
||||
build/powder-release: LFLAGS := -lSDL -lm -lbz2 -llua
|
||||
build/powder: CFLAGS += -DLIN32
|
||||
build/powder: LFLAGS := -lSDL -lm -lbz2
|
||||
build/powder: LFLAGS := -lSDL -lm -lbz2 -llua
|
||||
|
||||
build/powder-release.exe: $(SOURCES) build/powder-res.o
|
||||
$(CPPC_WIN) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(SOURCES) $(LFLAGS) build/powder-res.o -o $@
|
||||
@ -38,8 +38,8 @@ build/powder-release: $(SOURCES)
|
||||
$(CPPC) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(SOURCES) $(LFLAGS) -o $@
|
||||
strip $@
|
||||
|
||||
build/powder.exe: buildpaths-powder.exe $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS))
|
||||
$(CPPC_WIN) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) $(LFLAGS) -o $@ -ggdb
|
||||
build/powder.exe: buildpaths-powder.exe $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) build/powder-res.o
|
||||
$(CPPC_WIN) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) build/powder-res.o $(LFLAGS) -o $@ -ggdb
|
||||
build/obj/powder.exe/%.o: src/%.cpp $(HEADERS)
|
||||
$(CPPC_WIN) -c $(CFLAGS) $(OFLAGS) -o $@ $< -ggdb
|
||||
buildpaths-powder.exe:
|
||||
|
@ -11,14 +11,15 @@
|
||||
#include "CommandInterface.h"
|
||||
#include "game/GameModel.h"
|
||||
|
||||
CommandInterface::CommandInterface() {
|
||||
}
|
||||
|
||||
void CommandInterface::AttachGameModel(GameModel * m)
|
||||
{
|
||||
CommandInterface::CommandInterface(GameModel * m) {
|
||||
this->m = m;
|
||||
}
|
||||
|
||||
/*void CommandInterface::AttachGameModel(GameModel * m)
|
||||
{
|
||||
this->m = m;
|
||||
}*/
|
||||
|
||||
int CommandInterface::Command(std::string command)
|
||||
{
|
||||
lastError = "No interpreter";
|
||||
|
@ -14,14 +14,14 @@
|
||||
class GameModel;
|
||||
class CommandInterface {
|
||||
protected:
|
||||
enum FormatType { FormatInt, FormatString, FormatChar, FormatFloat };
|
||||
std::string lastError;
|
||||
GameModel * m;
|
||||
public:
|
||||
CommandInterface();
|
||||
enum FormatType { FormatInt, FormatString, FormatChar, FormatFloat };
|
||||
CommandInterface(GameModel * m);
|
||||
int GetPropertyOffset(std::string key_, FormatType & format);
|
||||
int GetParticleType(std::string type);
|
||||
void AttachGameModel(GameModel * m);
|
||||
//void AttachGameModel(GameModel * m);
|
||||
virtual void Tick() {}
|
||||
virtual int Command(std::string command);
|
||||
virtual std::string FormatCommand(std::string command);
|
||||
|
126
src/cat/LuaScriptHelper.h
Normal file
126
src/cat/LuaScriptHelper.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* LuaScriptHelper.h
|
||||
*
|
||||
* Created on: Feb 12, 2012
|
||||
* Author: Simon
|
||||
*/
|
||||
|
||||
#ifndef LUASCRIPTHELPER_H_
|
||||
#define LUASCRIPTHELPER_H_
|
||||
|
||||
GameModel * luacon_model;
|
||||
Simulation * luacon_sim;
|
||||
LuaScriptInterface * luacon_ci;
|
||||
Graphics * luacon_g;
|
||||
|
||||
int *lua_el_func, *lua_el_mode;
|
||||
|
||||
int getPartIndex_curIdx;
|
||||
int step_functions[6];//[6] = {0, 0, 0, 0, 0, 0};
|
||||
int keypress_function_count;// = 0;
|
||||
int *keypress_functions;// = NULL;
|
||||
int mouseclick_function_count;// = 0;
|
||||
int *mouseclick_functions;// = NULL;
|
||||
int tptProperties; //Table for some TPT properties
|
||||
int tptPropertiesVersion;
|
||||
int tptElements; //Table for TPT element names
|
||||
int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
||||
|
||||
|
||||
int luacon_step(int mx, int my, int selectl, int selectr);
|
||||
int luacon_mouseevent(int mx, int my, int mb, int event);
|
||||
int luacon_keyevent(int key, int modifier, int event);
|
||||
int luacon_eval(char *command);
|
||||
int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt);
|
||||
char *luacon_geterror();
|
||||
void luacon_close();
|
||||
int luacon_partsread(lua_State* l);
|
||||
int luacon_partswrite(lua_State* l);
|
||||
int luacon_partread(lua_State* l);
|
||||
int luacon_partwrite(lua_State* l);
|
||||
int luacon_elementread(lua_State* l);
|
||||
int luacon_elementwrite(lua_State* l);
|
||||
int luacon_transitionread(lua_State* l);
|
||||
int luacon_transitionwrite(lua_State* l);
|
||||
int luacon_particle_getproperty(char * key, int * format);
|
||||
int luacon_transition_getproperty(char * key, int * format);
|
||||
int luacon_element_getproperty(char * key, int * format, unsigned int * modified_stuff);
|
||||
//int process_command_lua(pixel *vid_buf, char *console, char *console_error);
|
||||
|
||||
//Interface
|
||||
int luatpt_test(lua_State* l);
|
||||
int luatpt_getelement(lua_State *l);
|
||||
int luatpt_element_func(lua_State *l);
|
||||
int luatpt_error(lua_State* l);
|
||||
int luatpt_drawtext(lua_State* l);
|
||||
|
||||
int luatpt_create(lua_State* l);
|
||||
|
||||
int luatpt_setpause(lua_State* l);
|
||||
|
||||
int luatpt_togglepause(lua_State* l);
|
||||
|
||||
int luatpt_togglewater(lua_State* l);
|
||||
|
||||
int luatpt_setconsole(lua_State* l);
|
||||
int luatpt_log(lua_State* l);
|
||||
|
||||
int luatpt_set_pressure(lua_State* l);
|
||||
|
||||
int luatpt_set_gravity(lua_State* l);
|
||||
int luatpt_reset_gravity_field(lua_State* l);
|
||||
|
||||
int luatpt_reset_velocity(lua_State* l);
|
||||
|
||||
int luatpt_reset_spark(lua_State* l);
|
||||
|
||||
int luatpt_set_property(lua_State* l);
|
||||
|
||||
int luatpt_get_property(lua_State* l);
|
||||
|
||||
int luatpt_drawpixel(lua_State* l);
|
||||
|
||||
int luatpt_drawrect(lua_State* l);
|
||||
|
||||
int luatpt_fillrect(lua_State* l);
|
||||
|
||||
int luatpt_drawline(lua_State* l);
|
||||
|
||||
int luatpt_textwidth(lua_State* l);
|
||||
int luatpt_get_name(lua_State* l);
|
||||
|
||||
int luatpt_set_shortcuts(lua_State* l);
|
||||
|
||||
int luatpt_delete(lua_State* l);
|
||||
int luatpt_register_step(lua_State* l);
|
||||
int luatpt_unregister_step(lua_State* l);
|
||||
int luatpt_register_keypress(lua_State* l);
|
||||
int luatpt_unregister_keypress(lua_State* l);
|
||||
int luatpt_register_mouseclick(lua_State* l);
|
||||
int luatpt_unregister_mouseclick(lua_State* l);
|
||||
int luatpt_input(lua_State* l);
|
||||
int luatpt_message_box(lua_State* l);
|
||||
int luatpt_get_numOfParts(lua_State* l);
|
||||
int luatpt_start_getPartIndex(lua_State* l);
|
||||
int luatpt_next_getPartIndex(lua_State* l);
|
||||
int luatpt_getPartIndex(lua_State* l);
|
||||
int luatpt_hud(lua_State* l);
|
||||
int luatpt_gravity(lua_State* l);
|
||||
int luatpt_airheat(lua_State* l);
|
||||
int luatpt_active_menu(lua_State* l);
|
||||
int luatpt_decorations_enable(lua_State* l);
|
||||
|
||||
int luatpt_heat(lua_State* l);
|
||||
int luatpt_cmode_set(lua_State* l);
|
||||
int luatpt_setfire(lua_State* l);
|
||||
int luatpt_setdebug(lua_State* l);
|
||||
|
||||
int luatpt_setfpscap(lua_State* l);
|
||||
|
||||
int luatpt_getscript(lua_State* l);
|
||||
|
||||
int luatpt_setwindowsize(lua_State* l);
|
||||
|
||||
int luatpt_screenshot(lua_State* l);
|
||||
|
||||
#endif /* LUASCRIPTHELPER_H_ */
|
1897
src/cat/LuaScriptInterface.cpp
Normal file
1897
src/cat/LuaScriptInterface.cpp
Normal file
File diff suppressed because it is too large
Load Diff
47
src/cat/LuaScriptInterface.h
Normal file
47
src/cat/LuaScriptInterface.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* LuaScriptInterface.h
|
||||
*
|
||||
* Created on: Feb 11, 2012
|
||||
* Author: Simon
|
||||
*/
|
||||
|
||||
#ifndef LUASCRIPTINTERFACE_H_
|
||||
#define LUASCRIPTINTERFACE_H_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <lua5.1/lua.h>
|
||||
#include <lua5.1/lauxlib.h>
|
||||
#include <lua5.1/lualib.h>
|
||||
}
|
||||
|
||||
#include "CommandInterface.h"
|
||||
#include "simulation/Simulation.h";
|
||||
|
||||
//Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :(
|
||||
|
||||
#define LOCAL_LUA_DIR "Lua"
|
||||
|
||||
#define LUACON_MDOWN 1
|
||||
#define LUACON_MUP 2
|
||||
#define LUACON_MPRESS 3
|
||||
#define LUACON_KDOWN 1
|
||||
#define LUACON_KUP 2
|
||||
|
||||
//Bitmasks for things that might need recalculating after changes to tpt.el
|
||||
#define LUACON_EL_MODIFIED_CANMOVE 0x1
|
||||
#define LUACON_EL_MODIFIED_GRAPHICS 0x2
|
||||
#define LUACON_EL_MODIFIED_MENUS 0x4
|
||||
|
||||
class LuaScriptInterface: public CommandInterface {
|
||||
public:
|
||||
lua_State *l;
|
||||
LuaScriptInterface(GameModel * m);
|
||||
virtual void Tick();
|
||||
virtual int Command(std::string command);
|
||||
virtual std::string FormatCommand(std::string command);
|
||||
virtual ~LuaScriptInterface();
|
||||
};
|
||||
|
||||
|
||||
#endif /* LUASCRIPTINTERFACE_H_ */
|
@ -14,7 +14,8 @@
|
||||
#include "TPTScriptInterface.h"
|
||||
#include "game/GameModel.h"
|
||||
|
||||
TPTScriptInterface::TPTScriptInterface() {
|
||||
TPTScriptInterface::TPTScriptInterface(GameModel * m): CommandInterface(m)
|
||||
{
|
||||
}
|
||||
|
||||
int TPTScriptInterface::Command(std::string command)
|
||||
|
@ -17,7 +17,7 @@ protected:
|
||||
AnyType tptS_set(std::deque<std::string> * words);
|
||||
ValueType testType(std::string word);
|
||||
public:
|
||||
TPTScriptInterface();
|
||||
TPTScriptInterface(GameModel * m);
|
||||
virtual void Tick() {}
|
||||
virtual int Command(std::string command);
|
||||
virtual std::string FormatCommand(std::string command);
|
||||
|
@ -79,8 +79,8 @@ GameController::GameController():
|
||||
gameView->AttachController(this);
|
||||
gameModel->AddObserver(gameView);
|
||||
|
||||
commandInterface = new TPTScriptInterface();
|
||||
commandInterface->AttachGameModel(gameModel);
|
||||
commandInterface = new LuaScriptInterface(gameModel);//new TPTScriptInterface();
|
||||
//commandInterface->AttachGameModel(gameModel);
|
||||
|
||||
//sim = new Simulation();
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
#include "login/LoginController.h"
|
||||
#include "ssave/SSaveController.h"
|
||||
#include "console/ConsoleController.h"
|
||||
#include "cat/TPTScriptInterface.h"
|
||||
//#include "cat/TPTScriptInterface.h"
|
||||
#include "cat/LuaScriptInterface.h"
|
||||
#include "Menu.h"
|
||||
|
||||
using namespace std;
|
||||
|
Loading…
Reference in New Issue
Block a user