summaryrefslogtreecommitdiff
path: root/lib/core/objects.lua
blob: 97320b82afb4eef10e017060392e871a330c8b41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- SYSTEM FILE
--
-- Lua object funtions
--

function create_object(tval, sval)
	local obj = new_object()
	object_prep(obj, lookup_kind(tval, sval))
	return (obj)
end

function set_item_tester(tester)
	if tolua.type(tester) == "number" then
		lua_set_item_tester(tester, "")
	end
	if tolua.type(tester) == "string" then
		lua_set_item_tester(0, tester)
	end
	if tolua.type(tester) == "function" then
		__get_item_hook_default = tester
		lua_set_item_tester(0, "__get_item_hook_default")
	end
end

function create_artifact(a_idx)
	local obj
	local tval, sval

	tval = a_info[a_idx + 1].tval
	sval = a_info[a_idx + 1].sval
	obj = create_object(tval, sval)
	obj.name1 = a_idx
	apply_magic(obj, -1, TRUE, TRUE, TRUE)

	return (obj)
end

function get_kind(obj)
	return k_info[obj.k_idx + 1]
end

function get_item(ask, deny, flags, mask)
	set_item_tester(mask)
	return get_item_aux(0, ask, deny, flags)
end