Reduced script verbosity to a degree
This commit is contained in:
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "map_system_api.hpp"
|
|
||||||
|
|
||||||
//all map API headers
|
|
||||||
#include "region_api.hpp"
|
|
||||||
#include "region_pager_api.hpp"
|
|
||||||
|
|
||||||
//useful "globals"
|
|
||||||
//...
|
|
||||||
|
|
||||||
//This mimics linit.c to create a nested collection of all map modules.
|
|
||||||
static const luaL_Reg funcs[] = {
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const luaL_Reg libs[] = {
|
|
||||||
{"Region", openRegionAPI},
|
|
||||||
{"RegionPager", openRegionPagerAPI},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
int openMapSystemAPI(lua_State* L) {
|
|
||||||
//create the table
|
|
||||||
luaL_newlibtable(L, libs);
|
|
||||||
|
|
||||||
//push the "global" functions
|
|
||||||
luaL_setfuncs(L, funcs, 0);
|
|
||||||
|
|
||||||
//push the substable
|
|
||||||
for (const luaL_Reg* lib = libs; lib->func; lib++) {
|
|
||||||
lib->func(L);
|
|
||||||
lua_setfield(L, -2, lib->name);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef MAPSYSTEMAPI_HPP_
|
|
||||||
#define MAPSYSTEMAPI_APP_
|
|
||||||
|
|
||||||
#include "lua.hpp"
|
|
||||||
|
|
||||||
#define TORTUGA_MAP_SYSTEM_API "map_system"
|
|
||||||
LUAMOD_API int openMapSystemAPI(lua_State* L);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
|
|
||||||
#define TORTUGA_REGION_NAME "region"
|
#define TORTUGA_REGION_API "region"
|
||||||
LUAMOD_API int openRegionAPI(lua_State* L);
|
LUAMOD_API int openRegionAPI(lua_State* L);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "region.hpp"
|
#include "region.hpp"
|
||||||
|
|
||||||
//DOCS: These glue functions simply wrap RegionPagerLua's methods
|
//DOCS: These glue functions simply wrap RegionPagerLua's methods
|
||||||
|
//NOTE: zero indexing is used here, but not in the region API
|
||||||
|
|
||||||
static int setTile(lua_State* L) {
|
static int setTile(lua_State* L) {
|
||||||
RegionPagerLua* pager = reinterpret_cast<RegionPagerLua*>(lua_touserdata(L, 1));
|
RegionPagerLua* pager = reinterpret_cast<RegionPagerLua*>(lua_touserdata(L, 1));
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
|
|
||||||
#define TORTUGA_REGION_PAGER_NAME "region_pager"
|
#define TORTUGA_REGION_PAGER_API "region_pager"
|
||||||
LUAMOD_API int openRegionPagerAPI(lua_State* L);
|
LUAMOD_API int openRegionPagerAPI(lua_State* L);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+25
-25
@@ -1,4 +1,4 @@
|
|||||||
local Region = require("map_system").Region
|
local regionAPI = require("region")
|
||||||
|
|
||||||
local mapMaker = {}
|
local mapMaker = {}
|
||||||
|
|
||||||
@@ -25,38 +25,38 @@ mapMaker.edges.west = -1
|
|||||||
function mapMaker.SmoothEdgesSimple(r)
|
function mapMaker.SmoothEdgesSimple(r)
|
||||||
--make and pad an array to use
|
--make and pad an array to use
|
||||||
local shiftArray = {}
|
local shiftArray = {}
|
||||||
for i = 1, Region.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
shiftArray[i] = {}
|
shiftArray[i] = {}
|
||||||
for j = 1, Region.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
shiftArray[i][j] = 0
|
shiftArray[i][j] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--build the array
|
--build the array
|
||||||
for i = 1, Region.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
for j = 1, Region.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
--if (not region edge) and (west tile < this tile), etc.
|
--if (not regionAPI edge) and (west tile < this tile), etc.
|
||||||
if i > 1 and Region.GetTile(r, i - 1, j, 1) < Region.GetTile(r, i, j, 1) then
|
if i > 1 and regionAPI.GetTile(r, i - 1, j, 1) < regionAPI.GetTile(r, i, j, 1) then
|
||||||
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.west
|
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.west
|
||||||
end
|
end
|
||||||
if j > 1 and Region.GetTile(r, i, j - 1, 1) < Region.GetTile(r, i, j, 1) then
|
if j > 1 and regionAPI.GetTile(r, i, j - 1, 1) < regionAPI.GetTile(r, i, j, 1) then
|
||||||
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.north
|
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.north
|
||||||
end
|
end
|
||||||
if i < Region.GetWidth(r) and Region.GetTile(r, i + 1, j, 1) < Region.GetTile(r, i, j, 1) then
|
if i < regionAPI.GetWidth(r) and regionAPI.GetTile(r, i + 1, j, 1) < regionAPI.GetTile(r, i, j, 1) then
|
||||||
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.east
|
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.east
|
||||||
end
|
end
|
||||||
if j < Region.GetHeight(r) and Region.GetTile(r, i, j + 1, 1) < Region.GetTile(r, i, j, 1) then
|
if j < regionAPI.GetHeight(r) and regionAPI.GetTile(r, i, j + 1, 1) < regionAPI.GetTile(r, i, j, 1) then
|
||||||
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.south
|
shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.south
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--finally apply this
|
--finally apply this
|
||||||
for i = 1, Region.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
for j = 1, Region.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
if shiftArray[i][j] ~= 0 then
|
if shiftArray[i][j] ~= 0 then
|
||||||
Region.SetTile(r, i, j, 2, Region.GetTile(r, i, j, 1) + shiftArray[i][j])
|
regionAPI.SetTile(r, i, j, 2, regionAPI.GetTile(r, i, j, 1) + shiftArray[i][j])
|
||||||
Region.SetTile(r, i, j, 1, Region.GetTile(r, i, j, 1) - 3)
|
regionAPI.SetTile(r, i, j, 1, regionAPI.GetTile(r, i, j, 1) - 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -65,27 +65,27 @@ end
|
|||||||
--custom generation systems here
|
--custom generation systems here
|
||||||
function mapMaker.DebugIsland(r)
|
function mapMaker.DebugIsland(r)
|
||||||
--basic distance check for each tile, placing an island around the world origin
|
--basic distance check for each tile, placing an island around the world origin
|
||||||
for i = 1, Region.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
for j = 1, Region.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
local dist = mapMaker.Dist(0, 0, i + Region.GetX(r) -1, j + Region.GetY(r) -1)
|
local dist = mapMaker.Dist(0, 0, i + regionAPI.GetX(r) -1, j + regionAPI.GetY(r) -1)
|
||||||
if dist < 10 then
|
if dist < 10 then
|
||||||
Region.SetTile(r, i, j, 1, mapMaker.plains)
|
regionAPI.SetTile(r, i, j, 1, mapMaker.plains)
|
||||||
elseif dist < 12 then
|
elseif dist < 12 then
|
||||||
Region.SetTile(r, i, j, 1, mapMaker.sand)
|
regionAPI.SetTile(r, i, j, 1, mapMaker.sand)
|
||||||
else
|
else
|
||||||
Region.SetTile(r, i, j, 1, mapMaker.water)
|
regionAPI.SetTile(r, i, j, 1, mapMaker.water)
|
||||||
Region.SetSolid(r, i, j, true)
|
regionAPI.SetSolid(r, i, j, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--examples of the smoothing function NOT working correctly
|
--examples of the smoothing function NOT working correctly
|
||||||
--[[
|
--[[
|
||||||
for j = 1, Region.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
Region.SetTile(r, 3, j, 1, mapMaker.dirt)
|
regionAPI.SetTile(r, 3, j, 1, mapMaker.dirt)
|
||||||
Region.SetTile(r, 4, j, 1, mapMaker.dirt)
|
regionAPI.SetTile(r, 4, j, 1, mapMaker.dirt)
|
||||||
|
|
||||||
Region.SetTile(r, 10, j, 1, mapMaker.dirt)
|
regionAPI.SetTile(r, 10, j, 1, mapMaker.dirt)
|
||||||
end
|
end
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
local Region = require("map_system").Region
|
local region = require("region")
|
||||||
|
|
||||||
local mapSaver = {}
|
local mapSaver = {}
|
||||||
|
|
||||||
function mapSaver.Load(r)
|
function mapSaver.Load(r)
|
||||||
--empty
|
--empty
|
||||||
io.write("map_saver:Load(", Region.GetX(r), ", ", Region.GetY(r), ")\n")
|
io.write("map_saver:Load(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
||||||
end
|
end
|
||||||
function mapSaver.Save(r)
|
function mapSaver.Save(r)
|
||||||
--empty
|
--empty
|
||||||
io.write("map_saver:Save(", Region.GetX(r), ", ", Region.GetY(r), ")\n")
|
io.write("map_saver:Save(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO: (3) create a flexible saving & loading system
|
--TODO: (3) create a flexible saving & loading system
|
||||||
|
|||||||
@@ -1,87 +1,55 @@
|
|||||||
print("Lua script check")
|
print("Lua script check")
|
||||||
|
|
||||||
|
--requirements
|
||||||
|
roomManagerAPI = require("room_manager")
|
||||||
|
roomAPI = require("room")
|
||||||
|
|
||||||
mapMaker = require("map_maker")
|
mapMaker = require("map_maker")
|
||||||
mapSaver = require("map_saver")
|
mapSaver = require("map_saver")
|
||||||
mapSystem = require("map_system")
|
|
||||||
roomSystem = require("room_system")
|
|
||||||
characterSystem = require("character_system")
|
|
||||||
networkSystem = require("network")
|
|
||||||
triggerSystem = require("trigger_system")
|
|
||||||
|
|
||||||
local function dumpTable(t)
|
|
||||||
print(t)
|
|
||||||
for k, v in pairs(t) do
|
|
||||||
print("",k,v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--test the room hooks
|
--test the room hooks
|
||||||
roomSystem.RoomManager.SetOnCreate(function(room, index)
|
roomManagerAPI.SetOnCreate(function(room, index)
|
||||||
print("", "Creating room: ", roomSystem.Room.GetName(room), index)
|
print("", "Creating room: ", roomAPI.GetName(room), index)
|
||||||
|
|
||||||
--called ~60 times per second
|
|
||||||
-- roomSystem.Room.SetOnTick(room, function(room)
|
|
||||||
-- roomSystem.Room.ForEachCharacter(room, function(character)
|
|
||||||
-- print(characterSystem.Character.GetHandle(character))
|
|
||||||
-- end)
|
|
||||||
--[[
|
|
||||||
local character = characterSystem.CharacterManager.GetCharacter("handle")
|
|
||||||
if character ~= nil then
|
|
||||||
--debugging
|
|
||||||
local originX, originY = characterSystem.Character.GetOrigin(character)
|
|
||||||
local motionX, motionY = characterSystem.Character.GetMotion(character)
|
|
||||||
if motionY < 0 then
|
|
||||||
characterSystem.Character.SetMotion(character, motionX, 0)
|
|
||||||
networkSystem.PumpCharacterUpdate(character)
|
|
||||||
print("Sending: ", motionX, motionY)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
-- end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
roomSystem.RoomManager.SetOnUnload(function(room, index)
|
roomManagerAPI.SetOnUnload(function(room, index)
|
||||||
print("", "Unloading room: ", roomSystem.Room.GetName(room), index)
|
print("", "Unloading room: ", roomAPI.GetName(room), index)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--NOTE: room 0 is the first that the client asks for, therefore it must exist
|
--NOTE: room 0 is the first that the client asks for, therefore it must exist
|
||||||
local overworld, uid = roomSystem.RoomManager.CreateRoom("overworld", "overworld.bmp")
|
local overworld, uid = roomManagerAPI.CreateRoom("overworld", "overworld.bmp")
|
||||||
roomSystem.Room.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save)
|
roomAPI.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save)
|
||||||
|
|
||||||
--debug: test the trigger system
|
--debug: test the trigger system
|
||||||
local pager = roomSystem.Room.GetPager(overworld)
|
--TODO: (0) What userdata type does the trigger script take as a parameter?
|
||||||
mapSystem.RegionPager.SetTile(pager, 0, 0, 0, mapMaker.dirt)
|
|
||||||
local triggerMgr = roomSystem.Room.GetTriggerMgr(overworld)
|
regionPagerAPI = require("region_pager")
|
||||||
--TODO: (1) What does the trigger script take as a parameter?
|
triggerManagerAPI = require("trigger_manager")
|
||||||
triggerSystem.TriggerManager.Create(triggerMgr, "dirt", 0, 0, 0, 0, 32, 32, function(character)
|
|
||||||
local x, y = characterSystem.Character.GetOrigin(character)
|
function createTrigger(handle, room, x, y, script)
|
||||||
characterSystem.Character.SetOrigin(character, x, y + 128)
|
local pager = roomAPI.GetPager(room)
|
||||||
networkSystem.PumpCharacterUpdate(character)
|
|
||||||
|
--place the indicator tile
|
||||||
|
regionPagerAPI.SetTile(pager, x, y, 0, mapMaker.dirt)
|
||||||
|
regionPagerAPI.SetTile(pager, x, y, 1, mapMaker.blank)
|
||||||
|
regionPagerAPI.SetTile(pager, x, y, 2, mapMaker.blank)
|
||||||
|
|
||||||
|
--create the trigger object
|
||||||
|
triggerManagerAPI.Create(
|
||||||
|
roomAPI.GetTriggerMgr(room), handle, x, y,
|
||||||
|
0, 0, 32, 32, --size of the tiles
|
||||||
|
script
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
characterAPI = require("character")
|
||||||
|
networkAPI = require("network")
|
||||||
|
|
||||||
|
--simple teleporter
|
||||||
|
createTrigger("trigger 1", overworld, 0, 0, function(character)
|
||||||
|
local x, y = characterAPI.GetOrigin(character)
|
||||||
|
characterAPI.SetOrigin(character, x, y + 128)
|
||||||
|
networkAPI.PumpCharacterUpdate(character)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--debugging
|
|
||||||
function dumpTrigger(t)
|
|
||||||
local originX, originY = triggerSystem.Trigger.GetOrigin(t)
|
|
||||||
local bx, by, bw, bh = triggerSystem.Trigger.GetBounds(t)
|
|
||||||
local s = triggerSystem.Trigger.GetScript(t)
|
|
||||||
print(triggerSystem.Trigger.GetHandle(t), originX, originY, bx, by, bw, bh, s)
|
|
||||||
end
|
|
||||||
|
|
||||||
function dumpTable(t)
|
|
||||||
for k, v in pairs(t) do
|
|
||||||
print("", k, v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
triggerMgr = roomSystem.Room.GetTriggerMgr(overworld)
|
|
||||||
trigger1, uid1 = triggerSystem.TriggerManager.Create(triggerMgr, "handle1")
|
|
||||||
trigger2, uid2 = triggerSystem.TriggerManager.Create(triggerMgr, "handle2", 30.2, 40.2)
|
|
||||||
trigger3, uid3 = triggerSystem.TriggerManager.Create(triggerMgr, "handle3", 30.2, 40.2, 0, 16, 32, 32, function() end)
|
|
||||||
|
|
||||||
dumpTrigger(trigger1)
|
|
||||||
dumpTrigger(trigger2)
|
|
||||||
dumpTrigger(trigger3)
|
|
||||||
--]]
|
|
||||||
|
|
||||||
print("Finished the lua script")
|
print("Finished the lua script")
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "character_system_api.hpp"
|
|
||||||
|
|
||||||
//all character API headers
|
|
||||||
#include "character_api.hpp"
|
|
||||||
#include "character_manager_api.hpp"
|
|
||||||
|
|
||||||
//useful "globals"
|
|
||||||
//...
|
|
||||||
|
|
||||||
//This mimics linit.c to create a nested collection of all character modules.
|
|
||||||
static const luaL_Reg funcs[] = {
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const luaL_Reg libs[] = {
|
|
||||||
{"Character", openCharacterAPI},
|
|
||||||
{"CharacterManager", openCharacterManagerAPI},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
int openCharacterSystemAPI(lua_State* L) {
|
|
||||||
//create the table
|
|
||||||
luaL_newlibtable(L, libs);
|
|
||||||
|
|
||||||
//push the "global" functions
|
|
||||||
luaL_setfuncs(L, funcs, 0);
|
|
||||||
|
|
||||||
//push the substable
|
|
||||||
for (const luaL_Reg* lib = libs; lib->func; lib++) {
|
|
||||||
lib->func(L);
|
|
||||||
lua_setfield(L, -2, lib->name);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef CHARACTERSYSTEMAPI_HPP_
|
|
||||||
#define CHARACTERSYSTEMAPI_HPP_
|
|
||||||
|
|
||||||
#include "lua.hpp"
|
|
||||||
|
|
||||||
#define TORTUGA_CHARACTER_SYSTEM_API "character_system"
|
|
||||||
LUAMOD_API int openCharacterSystemAPI(lua_State* L);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+20
-10
@@ -37,12 +37,17 @@
|
|||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
|
|
||||||
#include "entity_api.hpp"
|
#include "entity_api.hpp"
|
||||||
#include "character_system_api.hpp"
|
#include "character_api.hpp"
|
||||||
#include "map_system_api.hpp"
|
#include "character_manager_api.hpp"
|
||||||
#include "monster_system_api.hpp"
|
#include "region_api.hpp"
|
||||||
|
#include "region_pager_api.hpp"
|
||||||
|
#include "monster_api.hpp"
|
||||||
|
#include "monster_manager_api.hpp"
|
||||||
#include "network_api.hpp"
|
#include "network_api.hpp"
|
||||||
#include "room_system_api.hpp"
|
#include "room_api.hpp"
|
||||||
#include "trigger_system_api.hpp"
|
#include "room_manager_api.hpp"
|
||||||
|
#include "trigger_api.hpp"
|
||||||
|
#include "trigger_manager_api.hpp"
|
||||||
|
|
||||||
//these libs are loaded by lua.c and are readily available to any Lua program
|
//these libs are loaded by lua.c and are readily available to any Lua program
|
||||||
static const luaL_Reg loadedlibs[] = {
|
static const luaL_Reg loadedlibs[] = {
|
||||||
@@ -63,12 +68,17 @@ static const luaL_Reg loadedlibs[] = {
|
|||||||
//these libs are preloaded and must be required before used
|
//these libs are preloaded and must be required before used
|
||||||
static const luaL_Reg preloadedlibs[] = {
|
static const luaL_Reg preloadedlibs[] = {
|
||||||
{TORTUGA_ENTITY_API, openEntityAPI}, //required by derived classes
|
{TORTUGA_ENTITY_API, openEntityAPI}, //required by derived classes
|
||||||
{TORTUGA_CHARACTER_SYSTEM_API, openCharacterSystemAPI},
|
{TORTUGA_CHARACTER_API, openCharacterAPI},
|
||||||
{TORTUGA_MAP_SYSTEM_API, openMapSystemAPI},
|
{TORTUGA_CHARACTER_MANAGER_API, openCharacterManagerAPI},
|
||||||
{TORTUGA_MONSTER_SYSTEM_API, openMonsterSystemAPI},
|
{TORTUGA_MONSTER_API, openMonsterAPI},
|
||||||
|
{TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI},
|
||||||
{TORTUGA_NETWORK_API, openNetworkAPI},
|
{TORTUGA_NETWORK_API, openNetworkAPI},
|
||||||
{TORTUGA_ROOM_SYSTEM_API, openRoomSystemAPI},
|
{TORTUGA_REGION_API, openRegionAPI},
|
||||||
{TORTUGA_TRIGGER_SYSTEM_API, openTriggerSystemAPI},
|
{TORTUGA_REGION_PAGER_API, openRegionPagerAPI},
|
||||||
|
{TORTUGA_ROOM_API, openRoomAPI},
|
||||||
|
{TORTUGA_ROOM_MANAGER_API, openRoomManagerAPI},
|
||||||
|
{TORTUGA_TRIGGER_API, openTriggerAPI},
|
||||||
|
{TORTUGA_TRIGGER_MANAGER_API, openTriggerManagerAPI},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "monster_system_api.hpp"
|
|
||||||
|
|
||||||
//all monster API headers
|
|
||||||
#include "monster_api.hpp"
|
|
||||||
#include "monster_manager_api.hpp"
|
|
||||||
|
|
||||||
//useful "globals"
|
|
||||||
//...
|
|
||||||
|
|
||||||
//This mimics linit.c to create a nested collection of all monster modules.
|
|
||||||
static const luaL_Reg funcs[] = {
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const luaL_Reg libs[] = {
|
|
||||||
{"Monster", openMonsterAPI},
|
|
||||||
{"MonsterManager", openMonsterManagerAPI},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
int openMonsterSystemAPI(lua_State* L) {
|
|
||||||
//create the table
|
|
||||||
luaL_newlibtable(L, libs);
|
|
||||||
|
|
||||||
//push the "global" functions
|
|
||||||
luaL_setfuncs(L, funcs, 0);
|
|
||||||
|
|
||||||
//push the substable
|
|
||||||
for (const luaL_Reg* lib = libs; lib->func; lib++) {
|
|
||||||
lib->func(L);
|
|
||||||
lua_setfield(L, -2, lib->name);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef MONSTERSYSTEMAPI_HPP_
|
|
||||||
#define MONSTERSYSTEMAPI_HPP_
|
|
||||||
|
|
||||||
#include "lua.hpp"
|
|
||||||
|
|
||||||
#define TORTUGA_MONSTER_SYSTEM_API "monster_system"
|
|
||||||
LUAMOD_API int openMonsterSystemAPI(lua_State* L);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "room_system_api.hpp"
|
|
||||||
|
|
||||||
//all room API headers
|
|
||||||
#include "room_api.hpp"
|
|
||||||
#include "room_manager_api.hpp"
|
|
||||||
|
|
||||||
//useful "globals"
|
|
||||||
//...
|
|
||||||
|
|
||||||
//This mimics linit.c to create a nested collection of all room modules.
|
|
||||||
static const luaL_Reg funcs[] = {
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const luaL_Reg libs[] = {
|
|
||||||
{"Room", openRoomAPI},
|
|
||||||
{"RoomManager", openRoomManagerAPI},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
int openRoomSystemAPI(lua_State* L) {
|
|
||||||
//create the table
|
|
||||||
luaL_newlibtable(L, libs);
|
|
||||||
|
|
||||||
//push the "global" functions
|
|
||||||
luaL_setfuncs(L, funcs, 0);
|
|
||||||
|
|
||||||
//push the substable
|
|
||||||
for (const luaL_Reg* lib = libs; lib->func; lib++) {
|
|
||||||
lib->func(L);
|
|
||||||
lua_setfield(L, -2, lib->name);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef ROOMSYSTEMAPI_HPP_
|
|
||||||
#define ROOMSYSTEMAPI_HPP_
|
|
||||||
|
|
||||||
#include "lua.hpp"
|
|
||||||
|
|
||||||
#define TORTUGA_ROOM_SYSTEM_API "room_system"
|
|
||||||
LUAMOD_API int openRoomSystemAPI(lua_State* L);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "trigger_system_api.hpp"
|
|
||||||
|
|
||||||
//all trigger API headers
|
|
||||||
#include "trigger_api.hpp"
|
|
||||||
#include "trigger_manager_api.hpp"
|
|
||||||
|
|
||||||
//useful "globals"
|
|
||||||
//...
|
|
||||||
|
|
||||||
//This mimics linit.c to create a nested collection of all trigger modules.
|
|
||||||
static const luaL_Reg funcs[] = {
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const luaL_Reg libs[] = {
|
|
||||||
{"Trigger", openTriggerAPI},
|
|
||||||
{"TriggerManager", openTriggerManagerAPI},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
int openTriggerSystemAPI(lua_State* L) {
|
|
||||||
//create the table
|
|
||||||
luaL_newlibtable(L, libs);
|
|
||||||
|
|
||||||
//push the "global" functions
|
|
||||||
luaL_setfuncs(L, funcs, 0);
|
|
||||||
|
|
||||||
//push the substable
|
|
||||||
for (const luaL_Reg* lib = libs; lib->func; lib++) {
|
|
||||||
lib->func(L);
|
|
||||||
lua_setfield(L, -2, lib->name);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef TRIGGERSYSTEMAPI_HPP_
|
|
||||||
#define TRIGGERSYSTEMAPI_HPP_
|
|
||||||
|
|
||||||
#include "lua.hpp"
|
|
||||||
|
|
||||||
#define TORTUGA_TRIGGER_SYSTEM_API "trigger_system"
|
|
||||||
LUAMOD_API int openTriggerSystemAPI(lua_State* L);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user