master
root 2020-08-12 23:03:47 +02:00
parent f01416db60
commit 1541d0071d
35 changed files with 488 additions and 70 deletions

19
.luacheckrc Normal file
View File

@ -0,0 +1,19 @@
unused_args = false
allow_defined_top = true
globals = {
"minetest",
"mobkit"
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings",
-- MTG
"default", "sfinv", "creative",
}

View File

@ -2,5 +2,10 @@ local modpath, modname, S = ...
local creative_mode = minetest.settings:get_bool("creative_mode")
assert(loadfile(modpath .. "/api/api_on_die.lua"))(S)
function sama:get_pointed_thing()
end
assert(loadfile(modpath .. "/api/api_on_die.lua"))(S)
assert(loadfile(modpath .. "/api/api_container.lua"))(S)

159
api/api_container.lua Normal file
View File

@ -0,0 +1,159 @@
local modpath, S = ...
sama.container = {}
sama.container.open_containers = {}
function sama.container.get_container_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local formspec =
"size[8,7]" ..
"list[nodemeta:" .. spos .. ";main;2,1.3;4,1;]" ..
"list[current_player;main;0,2.85;8,1;]" ..
"list[current_player;main;0,4.08;8,3;8]" ..
"listring[nodemeta:" .. spos .. ";main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,2.85)
return formspec
end
function sama.container.container_lid_close(pn)
local container_open_info = sama.container.open_containers[pn]
local pos = container_open_info.pos
local sound = container_open_info.sound
local swap = container_open_info.swap
sama.container.open_containers[pn] = nil
for k, v in pairs(sama.container.open_containers) do
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
return true
end
end
local node = minetest.get_node(pos)
minetest.after(0.2, minetest.swap_node, pos, { name = "sama:" .. swap,
param2 = node.param2 })
minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
end
minetest.register_on_leaveplayer(function(player)
local pn = player:get_player_name()
if sama.container.open_containers[pn] then
sama.container.container_lid_close(pn)
end
end)
function sama.container.container_lid_obstructed(pos, direction)
if direction == "above" then
pos = {x = pos.x, y = pos.y + 1, z = pos.z}
end
local def = minetest.registered_nodes[minetest.get_node(pos).name]
-- allow ladders, signs, wallmounted things and torches to not obstruct
if def and
(def.drawtype == "airlike" or
def.drawtype == "signlike" or
def.drawtype == "torchlike" or
(def.drawtype == "nodebox" and def.paramtype2 == "wallmounted")) then
return false
end
return true
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "sama:container" then
return
end
if not player or not fields.quit then
return
end
local pn = player:get_player_name()
if not sama.container.open_containers[pn] then
return
end
sama.container.container_lid_close(pn)
return true
end)
function sama.register_container(name, d)
local def = table.copy(d)
def.drawtype = 'mesh'
def.paramtype = "light"
def.paramtype2 = "facedir"
def.legacy_facedir_simple = true
def.is_ground_content = false
def.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", d.description)
local inv = meta:get_inventory()
inv:set_size("main", 4*1)
end
def.can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end
def.on_rightclick = function(pos, node, clicker)
minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
max_hear_distance = 10})
if not sama.container.container_lid_obstructed(pos, "above") then
minetest.swap_node(pos, {
name = "sama:" .. name .. "_open",
param2 = node.param2 })
end
minetest.after(0.2, minetest.show_formspec,
clicker:get_player_name(),
"sama:container", sama.container.get_container_formspec(pos))
sama.container.open_containers[clicker:get_player_name()] = { pos = pos, sound = def.sound_close, swap = name }
end
def.on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "main", drops)
drops[#drops+1] = "sama:" .. name
minetest.remove_node(pos)
return drops
end
def.on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
minetest.log("action", player:get_player_name() ..
" moves stuff in container at " .. minetest.pos_to_string(pos))
end
def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves " .. stack:get_name() ..
" to container at " .. minetest.pos_to_string(pos))
end
def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes " .. stack:get_name() ..
" from container at " .. minetest.pos_to_string(pos))
end
local def_opened = table.copy(def)
local def_closed = table.copy(def)
def_opened.nodebox = d.node_box_opened
for i = 1, #def_opened.tiles do
if type(def_opened.tiles[i]) == "string" then
def_opened.tiles[i] = {name = def_opened.tiles[i], backface_culling = true}
elseif def_opened.tiles[i].backface_culling == nil then
def_opened.tiles[i].backface_culling = true
end
end
def_opened.drop = "sama:" .. name
def_opened.groups.not_in_creative_inventory = 1
def_opened.selection_box = {
type = "fixed",
fixed = { -1/2, -1/2, -1/2, 1/2, 3/16, 1/2 },
}
def_opened.can_dig = function()
return false
end
def_opened.on_blast = function() end
minetest.register_node("sama:" .. name, def_closed)
minetest.register_node("sama:" .. name .. "_open", def_opened)
end

1
armor.lua Normal file
View File

@ -0,0 +1 @@

173
container.lua Normal file
View File

@ -0,0 +1,173 @@
local modpath, S = ...
sama.container = {}
sama.container.open_containers = {}
function sama.container.get_container_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local meta = minetest.get_meta(pos)
local christmas_msg = meta:get_string("christmas_msg")
if not(christmas_msg) or christmas_msg == "" then
christmas_msg = S("Merry Christmas")
end
local formspec =
"size[8,7]" ..
"image[0,0;1,1;sama_christmas_container_inv.png]"..
"label[1,0;"..christmas_msg.."]"..
"list[nodemeta:" .. spos .. ";main;2,1.3;4,1;]" ..
"list[current_player;main;0,2.85;8,1;]" ..
"list[current_player;main;0,4.08;8,3;8]" ..
"listring[nodemeta:" .. spos .. ";main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,2.85)
return formspec
end
function sama.container.container_lid_close(pn)
local container_open_info = sama.container.open_containers[pn]
local pos = container_open_info.pos
local sound = container_open_info.sound
local swap = container_open_info.swap
sama.container.open_containers[pn] = nil
for k, v in pairs(sama.container.open_containers) do
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
return true
end
end
local node = minetest.get_node(pos)
minetest.after(0.2, minetest.swap_node, pos, { name = "sama:" .. swap,
param2 = node.param2 })
minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
end
minetest.register_on_leaveplayer(function(player)
local pn = player:get_player_name()
if sama.container.open_containers[pn] then
sama.container.container_lid_close(pn)
end
end)
function sama.container.container_lid_obstructed(pos, direction)
if direction = "above" then
pos = {x = pos.x, y = pos.y + 1, z = pos.z}
end
local def = minetest.registered_nodes[minetest.get_node(pos).name]
-- allow ladders, signs, wallmounted things and torches to not obstruct
if def and
(def.drawtype == "airlike" or
def.drawtype == "signlike" or
def.drawtype == "torchlike" or
(def.drawtype == "nodebox" and def.paramtype2 == "wallmounted")) then
return false
end
return true
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "sama:container" then
return
end
if not player or not fields.quit then
return
end
local pn = player:get_player_name()
if not sama.container.open_containers[pn] then
return
end
sama.container.container_lid_close(pn)
return true
end)
function sama.register_container(name, d)
local def = table.copy(d)
def.drawtype = "mesh"
def.visual = "mesh"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.legacy_facedir_simple = true
def.is_ground_content = false
def.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", d.description)
local inv = meta:get_inventory()
inv:set_size("main", 4*1)
end
def.can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end
def.on_rightclick = function(pos, node, clicker)
minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
max_hear_distance = 10})
if not sama.container.container_lid_obstructed(pos, "above") then
minetest.swap_node(pos, {
name = "sama:" .. name .. "_open",
param2 = node.param2 })
end
minetest.after(0.2, minetest.show_formspec,
clicker:get_player_name(),
"sama:container", sama.container.get_container_formspec(pos))
sama.container.open_containers[clicker:get_player_name()] = { pos = pos, sound = def.sound_close, swap = name }
end
def.on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "main", drops)
drops[#drops+1] = "sama:" .. name
minetest.remove_node(pos)
return drops
end
def.on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
minetest.log("action", player:get_player_name() ..
" moves stuff in container at " .. minetest.pos_to_string(pos))
end
def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves " .. stack:get_name() ..
" to container at " .. minetest.pos_to_string(pos))
end
def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes " .. stack:get_name() ..
" from container at " .. minetest.pos_to_string(pos))
end
local def_opened = table.copy(def)
local def_closed = table.copy(def)
def_opened.mesh = "container_open.obj"
for i = 1, #def_opened.tiles do
if type(def_opened.tiles[i]) == "string" then
def_opened.tiles[i] = {name = def_opened.tiles[i], backface_culling = true}
elseif def_opened.tiles[i].backface_culling == nil then
def_opened.tiles[i].backface_culling = true
end
end
def_opened.drop = "sama:" .. name
def_opened.groups.not_in_creative_inventory = 1
def_opened.selection_box = {
type = "fixed",
fixed = { -1/2, -1/2, -1/2, 1/2, 3/16, 1/2 },
}
def_opened.can_dig = function()
return false
end
def_opened.on_blast = function() end
def_closed.mesh = nil
def_closed.drawtype = nil
def_closed.tiles[6] = def.tiles[5] -- swap textures around for "normal"
def_closed.tiles[5] = def.tiles[3] -- drawtype to make them match the mesh
def_closed.tiles[3] = def.tiles[3].."^[transformFX"
minetest.register_node("sama:" .. name, def_closed)
minetest.register_node("sama:" .. name .. "_open", def_opened)
end

7
formspec.lua Normal file
View File

@ -0,0 +1,7 @@
local formspec = {
"formspec_version[3]",
"real_coordinates[true]",
"position[1,1]",
"size[1,1]",
"image_button[0,0;1,1;sama_lips.png;btn_lips;;true;false;"
}

26
furniture.lua Normal file
View File

@ -0,0 +1,26 @@
sama.register_container("wardrove", {
description = S("Wardrove"),
tiles = {
"sama_christmas_container_top.png",
"sama_christmas_container_top.png",
"sama_christmas_container_side.png",
"sama_christmas_container_side.png",
"sama_christmas_container_front.png",
"sama_christmas_container_inside.png"
},
stack_max = 1,
sounds = default.node_sound_wood_defaults(),
sound_open = "default_chest_open",
sound_close = "default_chest_close",
groups = {choppy = 2, oddly_breakable_by_hand = 2},
})
minetest.register_craft({
type = "shaped",
output = "sama:christmas_present",
recipe = {
{"default:paper", "default:paper", "default:paper"},
{"dye:red", "default:container", "dye:yellow"},
{"default:paper", "default:paper", "default:paper"},
}
})

10
hud.lua Normal file
View File

@ -0,0 +1,10 @@
minetest.register_on_joinplayer(function(player)
local menu = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
text = "sama_hud_main.png",
scale = { x = 3, y = 3},
alignment = { x = 1, y = -1},
offset = {x = 0, y = -5},
})
end)

View File

@ -5,8 +5,6 @@
local modname = "sama"
local modpath = minetest.get_modpath(modname)
local mg_name = minetest.get_mapgen_setting("mg_name")
-- internationalization boilerplate
local S = minetest.get_translator(minetest.get_current_modname())
@ -17,7 +15,11 @@ local S = minetest.get_translator(minetest.get_current_modname())
sama = {}
-- Load the files
assert(loadfile(modpath .. "/samantha.lua"))
assert(loadfile(modpath .. "/behaviour.lua"))
assert(loadfile(modpath .. "/brain.lua"))
assert(loadfile(modpath .. "/api/api.lua"))(modpath, modname, S )
assert(loadfile(modpath .. "/api/api.lua"))(modpath, modname, S)
assert(loadfile(modpath .. "/samantha.lua"))()
assert(loadfile(modpath .. "/behaviour.lua"))()
assert(loadfile(modpath .. "/brain.lua"))()
assert(loadfile(modpath .. "/hud.lua"))()
assert(loadfile(modpath .. "/formspec.lua"))()
assert(loadfile(modpath .. "/on_rightclick.lua"))()
--assert(loadfile(modpath .. "/wardrove.lua"))(S)

View File

@ -1,5 +1,5 @@
name = sama
description = A Female Character for Minetest
depends = mobkit
depends = mobkit, default
optional_depends =
version =

BIN
models/female.b3d Normal file

Binary file not shown.

BIN
models/female.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

BIN
models/samantha.xcf Normal file

Binary file not shown.

13
models/wardrove.mtl Normal file
View File

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl none
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd /opt/minetest/games/juanchi/mods/sama/textures/sama_wardrove.png

47
models/wardrove.obj Normal file
View File

@ -0,0 +1,47 @@
# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
mtllib wardrove.mtl
o wardrove_nodebox1
v 0.500000 -0.500000 0.062500
v 0.500000 -0.500000 0.500000
v 0.500000 1.000000 0.500000
v 0.500000 1.000000 0.062500
v -0.500000 -0.500000 0.062500
v -0.500000 -0.500000 0.500000
v -0.500000 1.000000 0.500000
v -0.500000 1.000000 0.062500
vt 0.625000 1.000000
vt 0.500000 1.000000
vt 0.500000 0.250000
vt 0.625000 0.250000
vt 0.640625 1.000000
vt 0.500000 1.000000
vt 0.500000 0.250000
vt 0.640625 0.250000
vt 0.500000 0.250000
vt 0.500000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.250000
vt 1.000000 0.250000
vt 1.000000 1.000000
vt 0.500000 1.000000
vt 0.500000 0.250000
vt 0.000000 0.250000
vt 0.000000 0.000000
vt 0.500000 0.000000
vt 0.500000 0.250000
vt 0.000000 0.250000
vt 0.000000 0.000000
vt 0.500000 0.000000
vt 0.500000 0.250000
vn -1.0000 -0.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn 0.0000 -1.0000 0.0000
usemtl none
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/1 6/6/1 7/7/1 8/8/1
f 1/9/2 4/10/2 8/11/2 5/12/2
f 2/13/2 3/14/2 7/15/2 6/16/2
f 1/17/3 2/18/3 6/19/3 5/20/3
f 4/21/3 3/22/3 7/23/3 8/24/3

BIN
nodeboxes/wardrove.nbe Normal file

Binary file not shown.

Binary file not shown.

1
on_rightclick.lua Normal file
View File

@ -0,0 +1 @@

View File

@ -1,66 +1,8 @@
-- Samantha Definitions
local samantha = {}
-- Default player appearance
minetest.register_entity("sama:samantha" ,{
name = "Samantha",
drops = {
},
rotate = petz.settings.rotate,
physical = true,
stepheight = 0.1, --EVIL!
collide_with_objects = true,
collisionbox = collisionbox,
visual = petz.settings.visual,
mesh = mesh,
textures = textures,
visual_size = visual_size,
static_save = true,
get_staticdata = mobkit.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
max_speed = 2,
jump_height = 1.5,
view_range = 10,
lung_capacity = 10, -- seconds
max_hp = 8,
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
attack={range=0.5, damage_groups={fleshy=3}},
animation = {
walk={range={x=1, y=12}, speed=25, loop=true},
run={range={x=13, y=25}, speed=25, loop=true},
stand={
{range={x=26, y=46}, speed=5, loop=true},
{range={x=47, y=59}, speed=5, loop=true},
{range={x=82, y=94}, speed=5, loop=true},
},
},
sounds = {
},
logic = sama.brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
end,
on_rightclick = function(self, clicker)
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
--petz.on_step(self, dtime)
end,
on_die = sama.on_die(self, pos)
})
--petz:register_egg("petz:lamb", S("Lamb"), "petz_spawnegg_lamb.png", true)
end)

BIN
textures/furniture.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 KiB

BIN
textures/sama_hud_main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

BIN
textures/sama_lips.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
textures/sama_wardrove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

13
wardrove.lua Normal file
View File

@ -0,0 +1,13 @@
local S = ...
sama.register_container("wardrove", {
description = S("Wardrove"),
mesh = "wardrove.obj",
tiles = {
"sama_wardrove.png",
},
sounds = default.node_sound_wood_defaults(),
sound_open = "default_chest_open",
sound_close = "default_chest_close",
groups = {choppy = 2, oddly_breakable_by_hand = 2},
})