Skip to content

Instantly share code, notes, and snippets.

--[[
Notes:
Times returned from "minetest.get_timeofday()"
Numbers have been trimmed to 2 significant figures.
0 is 12:00 AM
0.23 is 5:30 AM
Beds Flowchart:
|- 1) on_rightclick() (beds:bed_name or any node:here) (function call beds.bed_rightclick(pos, player))
|
|
|--- i) Is it night time and a player? (Gone 6pm in local clock?)
| |
| |
|------ I) else, return, end
| |
@Jordach
Jordach / .lua
Created February 22, 2017 21:39
-- how to add your own textures to the wardrobe;
--[[
Make sure your textures are in greyscale, eg, from black to white in 0-255 steps
The engine prefers this colour as it is easier to look right once a player has
set their colour preferences for a specific piece of clothing.
The only non-colourable texture is the mouth, as that either lightly shades the mouth area or
You guessed: 65
Too Small!
Please input your guess.
66
You guessed: 66
Too Big!
Please input your guess.
You guessed: 65
Too Small!
Please input your guess.
66
You guessed: 66
Too Big!
Please input your guess.
@Jordach
Jordach / .lua
Created February 22, 2017 17:02
function wardrobe.load_user_data(player)
local pname = player:get_player_name()
-- load non-RGB choices
if player:get_attribute("wardrobe_choices") == nil then
wardrobe.formspec_selections[pname] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
print ("[Wardrobe] Failed Loading Texture Data for Player: " .. pname)
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections[pname]))
@Jordach
Jordach / .lua
Created February 22, 2017 16:55
wardrobe.formspec_selections_rgb[pname][22] = wardrobe.is_save_hex(fields.acc6)
if wardrobe.is_hex(fields.acc6) then
wardrobe.formspec_selections_rgb[pname][22] = fields.acc6
else
wardrobe.formspec_selections_rgb[pname][22] = "ffffff"
end
end
@Jordach
Jordach / .lua
Created February 22, 2017 14:10
function wardrobe.load_user_data(player)
local pname = player:get_player_name()
-- load non-RGB choices
if minetest.deserialize(player:get_attribute("wardrobe_choices")) == nil then
wardrobe.formspec_selections[pname] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
@Jordach
Jordach / .lua
Created February 22, 2017 11:50
entity[1]:set_properties({
textures = {
"ptextures_transparent.png",
"(wardrobe_skin.png^[multiply:#"..fields.skintone..")^"..
"(wardrobe_eyes_white_"..wardrobe.formspec_selections[pname][1]..".png^[multiply:#"..fields.ewhite..")^"..
"(wardrobe_eyes_pupil_"..wardrobe.formspec_selections[pname][2]..".png^[multiply:#"..fields.pcolour..")^"..
"(wardrobe_hair_"..wardrobe.formspec_selections[pname][3]..".png^[multiply:#"..fields.hairdye..")^"..
"(wardrobe_under_shirt_"..wardrobe.formspec_selections[pname][5]..".png^[multiply:#"..fields.undshirt..")^"..
"(wardrobe_under_shirt_"..wardrobe.formspec_selections[pname][6]..".png^[multiply:#"..fields.undshirt2..")^"..
"(wardrobe_socks_2.png^[multiply:#"..fields.socks..")^"..
function wardrobe.is_save_hex(textfield)
if string.match(textfield, "^[0-9a-fA-F]+$") and #textfield == 6 then
return textfield
else
return "ffffff"
end
end