From 3de93b6b837a083580da62f25c48b65f5b38d0f2 Mon Sep 17 00:00:00 2001 From: lmaddox Date: Mon, 11 Dec 2023 19:29:31 -0600 Subject: [PATCH] #4 --- TODO.MD | 3 ++ working_villagers/api.lua | 31 +++++++++++++++++---- working_villagers/jobs/dyemixer.lua | 6 ---- working_villagers/jobs/dyemixer_recipes.lua | 8 ++++++ working_villagers/mod.conf | 2 +- working_villagers/talking.lua | 13 +++++++++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/TODO.MD b/TODO.MD index d41f6e8..0793dd7 100644 --- a/TODO.MD +++ b/TODO.MD @@ -75,3 +75,6 @@ some appliances don't set a facedir, requiring specific facings for the huts appliance-handling bots' find_node() methods should find all nodes and distinguish between active/inactive nodes so e.g., composter, wafflemaker, etc., can juggle multiple appliances + + +deduplicate strings -- job tasks have cross-cutting features and the associated strings should be in one place diff --git a/working_villagers/api.lua b/working_villagers/api.lua index 37e3098..4f11c85 100644 --- a/working_villagers/api.lua +++ b/working_villagers/api.lua @@ -2,6 +2,8 @@ local log = working_villages.require("log") local cmnp = modutil.require("check_prefix","venus") +local colors = working_villages.require("jobs/dyemixer_recipes").colors +assert(#colors > 0) working_villages.animation_frames = { STAND = { x= 0, y= 79, }, @@ -1016,6 +1018,25 @@ function working_villages.register_villager(product_name, def) working_villages.manufacturing_data[name] = working_villages.manufacturing_data[name] + 1 create_inventory(self) + -- birthday + self.dob = minetest.get_day_count() + self.tod = minetest.get_timeofday() + self.day_count = minetest.get_day_count() + + -- favorite color + self.fave_color = colors[math.random(#colors)] + assert(self.fave_color ~= nil) + + -- randomized name + if minetest.get_modpath("getname") then + -- TODO get gender + --getname.masculineName() + --getname.feminineName() + self.nametag = getname.genderlessName() + -- TODO family names + -- TODO now that we've got a "username," we can register with HB-type mods + end + -- attach dummy item to new villager. minetest.add_entity(self.object:get_pos(), "working_villages:dummy_item") else @@ -1030,11 +1051,11 @@ function working_villages.register_villager(product_name, def) self.job_data = data["job_data"] self.state_info = data["state_info"] self.pos_data = data["pos_data"] - self.dob = minetest.get_day_count() - self.tod = minetest.get_timeofday() - self.day_count = minetest.get_day_count() - -- TODO favorite color - -- TODO + -- personality + self.dob = data["dob"] + self.tod = data["tod"] + self.day_count = data["day_count"] + self.fave_color = data["fave_color"] local inventory = create_inventory(self) for list_name, list in pairs(data["inventory"]) do diff --git a/working_villagers/jobs/dyemixer.lua b/working_villagers/jobs/dyemixer.lua index 30c2a6f..51def68 100644 --- a/working_villagers/jobs/dyemixer.lua +++ b/working_villagers/jobs/dyemixer.lua @@ -214,12 +214,6 @@ local function take_target(villager,stack)--,data,iteration) return (inv:room_for_item("main", stack)) end -local colors = { - "red", "blue", "cyan", "grey", "pink", "black", - "brown", "green", "white", "orange", "violet", "yellow", - "magenta", "dark_grey", "dark_green", -} - working_villages.register_job("working_villages:job_dyemixer", { description = "dyemixer (working_villages)", diff --git a/working_villagers/jobs/dyemixer_recipes.lua b/working_villagers/jobs/dyemixer_recipes.lua index 51aeb64..1bc7d5f 100644 --- a/working_villagers/jobs/dyemixer_recipes.lua +++ b/working_villagers/jobs/dyemixer_recipes.lua @@ -1,6 +1,14 @@ local dyemixer_recipes = {} local S = minetest.get_translator("working_villages") +local colors = { + "red", "blue", "cyan", "grey", "pink", "black", + "brown", "green", "white", "orange", "violet", "yellow", + "magenta", "dark_grey", "dark_green", +} +dyemixer_recipes.colors = colors + + -- TODO write a dependency management system function dyemixer_recipes.update_color_plan(self, target_color) assert(self ~= nil) diff --git a/working_villagers/mod.conf b/working_villagers/mod.conf index d2fa964..3f3581b 100644 --- a/working_villagers/mod.conf +++ b/working_villagers/mod.conf @@ -1,4 +1,4 @@ name = working_villages description = A mod adding villager NPCs that are doing predefined work. Big features are planned. depends = default -optional_depends = areas,doors,beds,modutil, mcg_lockworkshop,fakery,mcg_dyemixer,crafting_bench,decraft,iadiscordia, basic_materials,biofuel,claycrafter,composting,decraft,sleeping_mat, wine,farming,snowcone,waffles,church_candles +optional_depends = areas,doors,beds,modutil, mcg_lockworkshop,fakery,mcg_dyemixer,crafting_bench,decraft,iadiscordia, basic_materials,biofuel,claycrafter,composting,decraft,sleeping_mat, wine,farming,snowcone,waffles,church_candles, getname diff --git a/working_villagers/talking.lua b/working_villagers/talking.lua index 4589bff..286f484 100644 --- a/working_villagers/talking.lua +++ b/working_villagers/talking.lua @@ -122,6 +122,19 @@ end) forms.put_link("working_villages:talking_menu", "working_villages:current_time", "What time is it?") +forms.register_text_page("working_villages:fave_color", + function(villager) + assert(villager ~= nil) + local color = villager.fave_color + if color == nil then + return "I don't have a preference." + end + return "My favorite color is "..color +end) + +forms.put_link("working_villages:talking_menu", "working_villages:fave_color", + "What's your favorite color?") + -- TODO where do you live/work -- how to get there -- TODO Who's your daddy and what does he do -- TODO what do you need to do your job -- ie in general & rn specifically