Problems with simple database

Post Reply
Warschildren
Posts: 5
Joined: Tue May 28, 2013 4:53 pm

Problems with simple database

Post by Warschildren »

All right, not sure what I'm doing wrong...
Code: [show] | [select all] lua
db:create("Players", {friends={"name", "city", "notes"}, enemies={"name", "city", "notes"}})
This creates the database (does show up in files).
Code: [show] | [select all] lua
local mydb = db:get_database("Players");
db:add(mydb.friends, {name="Ayo", city="Rust"})
Gives me this error: "<./mudlet-lua/lua/DB.lua:1585: Attempt to access database that does not exist.>"

Looking at the string, I'm wondering if my db files are being directed to the wrong folder... C:\Users\Me\.config\mudlet\profiles\ParallelRPI

Any ideas?

Jor'Mox
Posts: 1154
Joined: Wed Apr 03, 2013 2:19 am

Re: Problems with simple database

Post by Jor'Mox »

A number of the database functions are broken. You would be better served by using tables and saving and loading those. You can essentially do the same things with them anyway.

Warschildren
Posts: 5
Joined: Tue May 28, 2013 4:53 pm

Re: Problems with simple database

Post by Warschildren »

All right, I'll do that.

Any good resources/threads about tables?

Jor'Mox
Posts: 1154
Joined: Wed Apr 03, 2013 2:19 am

Re: Problems with simple database

Post by Jor'Mox »

I use these:
http://wiki.mudlet.org/w/Manual:Lua_Functions
http://pgl.yoyo.org/luai/i/_

Also, the existing table.update function is broken, but a fix has been made that will be available in the next release. You can put this in your code somewhere to be able to use it until then:
Code: [show] | [select all] lua
function table.update(t1, t2)
	local tbl = {}
	for k,v in pairs(t1) do
		tbl[k] = v
	end
	for k,v in pairs(t2) do
		if type(v) == "table" then
			tbl[k] = table.update(tbl[k] or {}, v)
		else
			tbl[k] = v
		end
	end
	return tbl
end

Post Reply