diff --git a/app.lua b/app.lua index 4e3bee7..49da45a 100644 --- a/app.lua +++ b/app.lua @@ -6,6 +6,8 @@ local player = require('player') local db = require("lapis.db") local Model = require("lapis.db.model").Model +local db = Model:extend('database') + app:enable("etlua") app.layout = require "views.layout" @@ -58,5 +60,6 @@ return app + diff --git a/database.sqlite3 b/database.sqlite3 new file mode 100644 index 0000000..d5c7d88 Binary files /dev/null and b/database.sqlite3 differ diff --git a/setup_db b/setup_db new file mode 100755 index 0000000..6e67040 --- /dev/null +++ b/setup_db @@ -0,0 +1,24 @@ +#!/bin/bash + +sqlite3 database.sqlite3 " + CREATE TABLE IF NOT EXISTS map ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + x TEXT, + y TEXT, + occupied_by_type TEXT, + occupied_by_id INTEGER + ); + CREATE TABLE IF NOT EXISTS entity_ref ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + entity_id INTEGER, + type TEXT, + hp INTEGER, + inventory_ref INTEGER + ); + CREATE TABLE IF NOT EXISTS player_inventory ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + type TEXT, + quantity INTEGER, + func_ref TEXT + ) +"