added character editor

This commit is contained in:
cale 2016-02-13 12:08:15 +01:00
parent fba463ef4a
commit e0459d1783
6 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,16 @@
License for Code
----------------
Copyright (C) 2016 cd2 (cdqwertz) <cdqwertz@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
http://www.gnu.org/licenses/lgpl-2.1.html
License for Media
-----------------
CC-BY-SA 3.0 UNPORTED. Created by cd2 (cdqwertz)

View File

@ -0,0 +1,56 @@
character_editor = {}
character_editor.characters = {}
character_editor.mesh = {}
character_editor.shirts = {"character_editor_red_shirt.png", "character_editor_blue_shirt.png", "character_editor_yellow_shirt.png"}
function character_editor.update_character(player)
local name = player:get_player_name()
player:set_properties({
mesh = character_editor.mesh[name],
textures = {table.concat(character_editor.characters[name], "^")},
visual = "mesh",
visual_size = {x=1, y=1},
})
print(table.concat(character_editor.characters[name], "^"))
end
function character_editor.set_mesh(player, mesh)
local name = player:get_player_name()
character_editor.mesh[name] = mesh
character_editor.update_character(player)
end
function character_editor.set_texture(player, pos, texture)
local name = player:get_player_name()
if not character_editor.characters[name] then
character_editor.characters[name] = {}
end
character_editor.characters[name][pos] = texture
print(character_editor.characters[name][pos])
character_editor.update_character(player)
end
minetest.register_chatcommand("shirt", {
params = "<name>",
description = "[TEST CMD] Select your shirt",
privs = {interact = true},
func = function(plname , name)
local player = minetest.get_player_by_name(plname)
if character_editor.shirts[tonumber(name)] then
character_editor.set_texture(player, 2, character_editor.shirts[tonumber(name)])
return true, "You selected ".. name
else
return true, "There is no shirt named ".. name
end
end,
})
minetest.register_on_joinplayer(function(player)
character_editor.mesh[player:get_player_name()] = "character.x"
character_editor.characters[player:get_player_name()] = {}
character_editor.set_texture(player, 1, "character.png")
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

View File

@ -9,7 +9,7 @@ minetest.register_node("torch:torch", {
light_source = 14,
walkable = false,
inventory_image = "torch_torch_inv.png",
wield_image = "torch_torch_inv.png",
--wield_image = "torch_torch_inv.png",
})
minetest.register_abm({