From ed6d2f970545de74517eed01cd0770265ba5a66e Mon Sep 17 00:00:00 2001 From: Lunovox Date: Thu, 8 Aug 2024 09:02:00 -0300 Subject: [PATCH 1/2] --- components_smartphone.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 components_smartphone.lua diff --git a/components_smartphone.lua b/components_smartphone.lua new file mode 100644 index 0000000..936439e --- /dev/null +++ b/components_smartphone.lua @@ -0,0 +1,13 @@ + +modComponents.apps = { + installeds = {"appSettings"}, + repository = [ + ["appSettings"]={ + title=modComponents.translate("Settings"), + icon="icon_settings.png" + on_play = Function(player) + --qual janela irá abrir! + end, + }, + ], +} \ No newline at end of file From ebfeb13fc770758492e7e1dade5f65b93f31ccd9 Mon Sep 17 00:00:00 2001 From: Lunovox Date: Thu, 8 Aug 2024 11:27:11 -0300 Subject: [PATCH 2/2] =?UTF-8?q?[code][notested]=20Code=20of=20Smartphone.?= =?UTF-8?q?=20(talv=C3=A9s=20ser=C3=A1=20transferido=20para=20outro=20mod)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components_smartphone.lua | 91 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/components_smartphone.lua b/components_smartphone.lua index 936439e..24bb185 100644 --- a/components_smartphone.lua +++ b/components_smartphone.lua @@ -1,13 +1,96 @@ modComponents.apps = { - installeds = {"appSettings"}, - repository = [ + installeds = [ + --"appSettings" + ], + repository = { + --[[ ["appSettings"]={ title=modComponents.translate("Settings"), icon="icon_settings.png" + to_all_player = true, on_play = Function(player) --qual janela irá abrir! end, }, - ], -} \ No newline at end of file + --]] + }, + register_app = function(appname, def) + if type(appname)=="string" and appname~="" then + if type(def)=="table" + and type(def.title)=="string" and def.title~="" + and type(def.icon)=="string" and def.icon~="" + and type(def.to_all_player)=="boolean" + and type(def.on_play)=="function" + then + if type(modComponents.apps.repository[appname])~="table" then + modComponents.apps.repository[appname].title = def.title + modComponents.apps.repository[appname].icon = def.icon.."^[resize:32x32" + modComponents.apps.repository[appname].to_all_player = def.to_all_player + modComponents.apps.repository[appname].on_play = def.on_play + if def.to_all_player == true then + table.insert( + modComponents.apps.installeds, + appname + } + end + return true + else + return false, "[COMPONENTES:SMARTPHONE:ERROR] Não é possível instalar um app com mesmo nome." + end + else + return false, "[COMPONENTES:SMARTPHONE:ERROR] Definição inválida." + end + else + return false, "[COMPONENTES:SMARTPHONE:ERROR] Nome de App inválido!" + end + end, +} + +modComponents.apps.register_app("appSettings", { + title=modComponents.translate("Settings"), + icon="icon_settings.png" + to_all_player = true, + on_play = Function(player) + minetest.chat_send_player( + player:get_player_name(), + minetest.colorize("#FF0000", "[COMPONENTES:SMARTPHONE:ERROR] ") + ..modCorreio.translate("Function not implemented yet!") + ) + end, +}) + + +if minetest.get_modpath("correio") + and minetest.global_exists("modCorreio") + and type(modCorreio.openinbox)=="function" +then + modComponents.apps.register_app("appMail", { + title=modComponents.translate("Mails"), + icon="icon_mail2.png" + to_all_player = true, + on_play = Function(player) + modCorreio.openinbox(player:get_player_name()) + --qual janela irá abrir! + end, + }) +end + + +if minetest.get_modpath("minertrade") + and minetest.global_exists("modMinerTrade") + and type(modMinerTrade.showAccountBank)=="table" + and type(modMinerTrade.showAccountBank.inCreditCard)=="function" +then + modComponents.apps.register_app("appBank", { + title=modComponents.translate("Bank"), + icon="obj_piggy_bank.png" + to_all_player = true, + on_play = Function(player) + local playername = player:get_player_name() + modMinerTrade.showAccountBank.inCreditCard(playername, playername) + end, + }) +end + +