From e0459d1783e56323b1ff8ce40cf886abd53cb469 Mon Sep 17 00:00:00 2001 From: cale Date: Sat, 13 Feb 2016 12:08:15 +0100 Subject: [PATCH] added character editor --- mods/character_editor/LICENSE.txt | 16 +++++ mods/character_editor/init.lua | 56 ++++++++++++++++++ .../textures/character_editor_blue_shirt.png | Bin 0 -> 704 bytes .../textures/character_editor_red_shirt.png | Bin 0 -> 709 bytes .../character_editor_yellow_shirt.png | Bin 0 -> 699 bytes mods/torch/init.lua | 2 +- 6 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 mods/character_editor/LICENSE.txt create mode 100644 mods/character_editor/init.lua create mode 100644 mods/character_editor/textures/character_editor_blue_shirt.png create mode 100644 mods/character_editor/textures/character_editor_red_shirt.png create mode 100644 mods/character_editor/textures/character_editor_yellow_shirt.png diff --git a/mods/character_editor/LICENSE.txt b/mods/character_editor/LICENSE.txt new file mode 100644 index 0000000..6f6a256 --- /dev/null +++ b/mods/character_editor/LICENSE.txt @@ -0,0 +1,16 @@ +License for Code +---------------- + +Copyright (C) 2016 cd2 (cdqwertz) + +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) diff --git a/mods/character_editor/init.lua b/mods/character_editor/init.lua new file mode 100644 index 0000000..cbb16ac --- /dev/null +++ b/mods/character_editor/init.lua @@ -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 = "", + 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) + + diff --git a/mods/character_editor/textures/character_editor_blue_shirt.png b/mods/character_editor/textures/character_editor_blue_shirt.png new file mode 100644 index 0000000000000000000000000000000000000000..664406a8af154072d26da03051056a0229dec51a GIT binary patch literal 704 zcmV;x0zdtUP)Lo zK~#9!?OVNW!Y~lFEiYBpf?D-W7`kQY%+9m1GiT|Rfv4ybz=mL^lcmGl+2=TrR{1^& z1(Nvwe0M(oV9d;6$0YXk`F$;Uzw2AOS?{mM!^Ie5%wpLXV~pAER(4GOUEf;nS=YDL zPu&AS`S|;@;N~6zlY2mL`>DL(Pldq0_kgZ%?K9dS2fzR@01N;FzyJUM0000000000 zFcjjB33vZ={xQwVhk1K{y<5$d+ANlh+3r?Fd}v!OpP`GZZn13c*5)N)0%D=G?KSUF z#9L;MfQuCx!b~e@$sRzUMX!%Agp-8Q?$~GrE8PG|y&v0BS%x!#uCJeISj*J)dqa%)M*k|dOiTN;A7aFdiS@wPah`PiB? z_DdOR;ycyrDMOEOl7wsLY8sbhb8V3oyLnF8+WNo^8CG(`Anj3&G2-|xsXU8?Fd-UJ zT2rsQ@c>N)#|?uev7Vc;<$9m;3AA!X&2^m9#!KylskEoGiMUjGwh|m;@=~iX%_&1F z%Ap4Knt0@rAUA)gt<0qBn4UNFvAoF;k4Dny1ONa40000005A*KxhN`~DZn2l=Ayfv@p<^AJsHCJl0X|`t99g6tSwpu<@7gyb;+1{Q|fR?w0?fIy30A7Kb538me!(F#_&0g`$@=2v4Fry&$8Nx$b5lfs4L z#r<|UpKd-mV^rk;$|UF3+^#McO7S&iFpiGKQ);%?d`fVMxRf(!*47FYXZlp=Nk-Io z0j(T?XWI|fr~ zYtq;+WvGeoRIjHDJ;zBBuAQrCT$0VTgRI!ibIR6^58RZpk}HF>M>WQX1asxHBq4G-dFe=6s-#KJ11)OI@GLe=jWS_E zG-YUgQ`J&AprqDnV=y;k%k@6x)AoZ6^t3ZU+Hv9DY2&4K!c^K*+C*HcJUbGcWAaj~ zFwH4bMwC+x>^1SoB|&cfP&+b{u5)_c(#P@^LtKrd>I47)00000006KG*tIAsohiT{ rCf1}ZchTx?b literal 0 HcmV?d00001 diff --git a/mods/character_editor/textures/character_editor_yellow_shirt.png b/mods/character_editor/textures/character_editor_yellow_shirt.png new file mode 100644 index 0000000000000000000000000000000000000000..af49ce5a4685c1ea667b2ed1d30f9b9bc7a9bcc6 GIT binary patch literal 699 zcmV;s0!00ZP)j`0!T?j zK~#9!?ORJu!!QuFEpJekph~DWsSvv;7w9p20mLq+R{dzl`JA7-LM+Y>Y9+?A{J`PX2AzTkcug_0}&v z13`KE`=j929s-MdKydq|yx>oTz`yr^w(IR9#vlj405AXy00Y1P0000000000001x* z;*JS-|Lc1&+wGHid49cF&6UP9&BpBB4n=(8v06S;7gt@=Y;M-(C1C=nP}=dD_hQg3 zvwOf%g{Cmm3R+tuYliC$9%DR_<0J_;&eaSq$>!Q7i@JGE+1mcVO(`q6G8oUO#uzldOL~x!D!|e9QZLOX z$KmQZ6(H{W1HIF6e@V@HE(zw!XGucjbn?=Xv{Xrx?gv`2F~dD-m>Olm2ho()`nswm zj>zycF{oo$5`0S6$TekwR?euoiF4X`sr_IoohfZ1E>)iG1n2m8sZ}`6DN{PisRs6% zc;u2G_x(`YnMv0