Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional sprite version #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ local OPEN_BAG_SOUND = "prestibags_rustle_bag"
local OPEN_BAG_SOUND_GAIN = 1.0
local OPEN_BAG_SOUND_DIST = 5.0

-- Use mesed bag or cubic one with 16px texture
local MESHED_BAG = false

--- HP of undamaged bag (integer >0).
local BAG_MAX_HP = 4

Expand Down Expand Up @@ -53,6 +56,26 @@ local BURN_DAMAGE__HP = 1

local EPSILON = 0.001 -- "close enough"

-- Textures and bag
local bag_texture_inv
local bag_texture_wield
local bag_properties = {}

if MESHED_BAG then
bag_texture_inv = "prestibags_bag_inv.png"
bag_texture_wield = "prestibags_bag_wield.png"
bag_properties.visual = "mesh"
bag_properties.visual_size = { x = 1, y = 1 }
bag_properties.mesh = "prestibags_bag.obj"
bag_properties.textures = { "prestibags_bag.png" }
else
bag_texture_inv = "prestibags_bag_small.png"
bag_texture_wield = "prestibags_bag_small.png"
bag_properties.visual = "sprite"
bag_properties.visual_size = { x = 0.9, y = 1 }
bag_properties.mesh = nil
bag_properties.textures = {"prestibags_bag_small.png"}
end

local function serializeContents(contents)
if not contents then return "" end
Expand Down Expand Up @@ -159,10 +182,10 @@ minetest.register_entity(
hp_max = BAG_MAX_HP,
physical = false,
collisionbox = { -0.44, -0.5, -0.425, 0.44, 0.35, 0.425 },
visual = "mesh",
visual_size = { x = 1, y = 1 },
mesh = "prestibags_bag.obj",
textures = { "prestibags_bag.png" }
visual = bag_properties.visual,
visual_size = bag_properties.visual_size,
mesh = bag_properties.mesh,
textures = bag_properties.textures,
},

on_activate = function(self, staticData, dt)
Expand Down Expand Up @@ -228,7 +251,8 @@ minetest.register_entity(

local formspec =
"size["..w..","..h.."]"..
"image[1,"..yImg..";1,1;prestibags_bag_inv.png]"..
default.gui_bg_img..
"image[1,"..yImg..";1,1;"..bag_texture_inv.."]"..
"list[detached:prestibags:bags;"..self.id..";2,0;"..
BAG_WIDTH..","..BAG_HEIGHT..";]"..
"list[current_player;main;0,"..yPlay..";8,4;]"
Expand Down Expand Up @@ -384,8 +408,8 @@ minetest.register_tool(
{
description = "Bag of Stuff",
groups = { bag = BAG_WIDTH*BAG_HEIGHT, flammable = 1 },
inventory_image = "prestibags_bag_inv.png",
wield_image = "prestibags_bag_wield.png",
inventory_image = bag_texture_inv,
wield_image = bag_texture_wield,
stack_max = 1,

on_place = function(stack, player, pointedThing)
Expand Down
Binary file added textures/prestibags_bag_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.