aboutsummaryrefslogtreecommitdiff
path: root/src/sqlite
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-28 01:17:36 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:56 +0200
commit6029d9e5a956b6135e23dcfb4caccb74355ef4b1 (patch)
treea0c5f72e204a8f92d4fcfab391e6ff1b40028ad4 /src/sqlite
parent19a1ac1f34c8dba8ada039c916858e16e2637f36 (diff)
downloadminetest-6029d9e5a956b6135e23dcfb4caccb74355ef4b1.tar.gz
minetest-6029d9e5a956b6135e23dcfb4caccb74355ef4b1.tar.bz2
minetest-6029d9e5a956b6135e23dcfb4caccb74355ef4b1.zip
Comment fix in builtin.lua
Diffstat (limited to 'src/sqlite')
0 files changed, 0 insertions, 0 deletions
='n107' href='#n107'>107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
-- Minetest: builtin/item_entity.lua

function core.spawn_item(pos, item)
	-- Take item in any format
	local stack = ItemStack(item)
	local obj = core.add_entity(pos, "__builtin:item")
	obj:get_luaentity():set_item(stack:to_string())
	return obj
end

-- If item_entity_ttl is not set, enity will have default life time 
-- Setting it to -1 disables the feature

local time_to_live = tonumber(core.setting_get("item_entity_ttl"))
if not time_to_live then
	time_to_live = 900
end

core.register_entity(":__builtin:item", {
	initial_properties = {
		hp_max = 1,
		physical = true,
		collide_with_objects = false,
		collisionbox = {-0.24, -0.24, -0.24, 0.24, 0.24, 0.24},
		visual = "wielditem",
		visual_size = {x = 0.3, y = 0.3},
		textures = {""},
		spritediv = {x = 1, y = 1},
		initial_sprite_basepos = {x = 0, y = 0},
		is_visible = false,
	},

	itemstring = '',
	physical_state = true,
	age = 0,

	set_item = function(self, itemstring)
		self.itemstring = itemstring
		local stack = ItemStack(itemstring)
		local count = stack:get_count()
		local max_count = stack:get_stack_max()
		if count > max_count then
			count = max_count
			self.itemstring = stack:get_name().." "..max_count
		end
		local s = 0.15 + 0.15 * (count / max_count)
		local c = 0.8 * s
		local itemtable = stack:to_table()
		local itemname = nil
		if itemtable then
			itemname = stack:to_table().name
		end
		local item_texture = nil
		local item_type = ""
		if core.registered_items[itemname] then
			item_texture = core.registered_items[itemname].inventory_image
			item_type = core.registered_items[itemname].type
		end
		prop = {
			is_visible = true,