From 59f7d72a51ebc07690365c8dce7a90da288abd05 Mon Sep 17 00:00:00 2001 From: tacigar Date: Fri, 16 Sep 2016 22:37:18 +0900 Subject: [PATCH] [UPDATE] Use infotext of maidroid --- maidroid/api.lua | 22 ++++++++++++++++++++++ maidroid_core/cores/basic.lua | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/maidroid/api.lua b/maidroid/api.lua index dad6167..9cf5615 100644 --- a/maidroid/api.lua +++ b/maidroid/api.lua @@ -163,6 +163,22 @@ function maidroid.register_maidroid(product_name, def) maidroid.manufacturing_data[product_name] = 0 end + local function update_infotext(self) + if self.core_name ~= "" then + local infotext = "" + if self.pause then + infotext = infotext .. "this maidroid is paused\n" + else + infotext = infotext .. "this maidroid is active\n" + end + infotext = infotext .. "[Core] : " .. self.core_name + + self.object:set_properties{infotext = infotext} + return + end + self.object:set_properties{infotext = "this maidroid is inactive"} + end + -- create_inventory creates a new inventory, and returns it. local function create_inventory(self) self.inventory_name = self.product_name .. tostring(self.manufacturing_number) @@ -173,6 +189,8 @@ function maidroid.register_maidroid(product_name, def) local core = maidroid.registered_cores[core_name] core.on_start(self) self.core_name = core_name + + update_infotext(self) end end, @@ -191,6 +209,8 @@ function maidroid.register_maidroid(product_name, def) local core = maidroid.registered_cores[self.core_name] self.core_name = "" core.on_stop(self) + + update_infotext(self) end end, }) @@ -244,6 +264,7 @@ function maidroid.register_maidroid(product_name, def) end self.formspec_string = create_formspec_string(self) + update_infotext(self) local core = self:get_core() if core ~= nil then @@ -326,6 +347,7 @@ function maidroid.register_maidroid(product_name, def) is_visible = true, makes_footstep_sound = true, automatic_face_movement_dir = 90.0, + infotext = "", -- extra initial properties pause = false, diff --git a/maidroid_core/cores/basic.lua b/maidroid_core/cores/basic.lua index 23f6b2f..26dc95d 100644 --- a/maidroid_core/cores/basic.lua +++ b/maidroid_core/cores/basic.lua @@ -13,7 +13,7 @@ end local function on_stop(self) self.state = nil - self.object:setvelocty{x = 0, y = 0, z = 0} + self.object:setvelocity{x = 0, y = 0, z = 0} end local on_resume = on_start