From bec54003886d9280c5ceedcab2f42284b64394c8 Mon Sep 17 00:00:00 2001 From: Lunovox Date: Mon, 18 Nov 2024 10:02:54 -0300 Subject: [PATCH] --- api.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++ init.lua | 12 ++++++ item_smartphone.lua | 15 ++++++++ mod.conf | 2 + 4 files changed, 123 insertions(+) create mode 100644 api.lua create mode 100644 init.lua create mode 100644 item_smartphone.lua create mode 100644 mod.conf diff --git a/api.lua b/api.lua new file mode 100644 index 0000000..4aa252e --- /dev/null +++ b/api.lua @@ -0,0 +1,94 @@ +modComputing.apps = { } + +modComputing.debug = function(text, playername) + if text ~= nil + and type(text) == "string" + and text ~= "" + then + if core.settings:get_bool(modComputing.modname..".debug") then + if playername ~= nil + and type(playername) == "string" + and playername ~= "" + then + local player = core.get_player_by_name(playername) + if player ~=nil and player:is_player() then + core.chat_send_player( + playername, text + ) + core.log('action',"["..modComputing.modname:upper()..":DEBUG:"..playername.."] "..text) + else + core.log('error', + "["..modComputing.modname:upper()..":DEBUG] " + ..modComputing.translate( + "Unable to address debug for player '%s'." + ):format(dump(playername)) + ) + core.log('action',"["..modComputing.modname:upper()..":DEBUG] "..text) + end + else + core.chat_send_all(text) + core.log('action',"["..modComputing.modname:upper()..":DEBUG] "..text) + end + end + end +end + +modComputing.log() = function(text) + local sufix = "["..modComputing.modname:upper()..":ERRO] " + core.chat_send_all(sufix..text) + core.log('action',sufix..text) + return sufix..text +end + +modComputing.add_app = function(appname, def) + if type(appname)=="string" and appname~="" then + if type(modComputing.apps[appname])!="table" then + if type(def.iconname)=="string" and def.iconname~="" then + if type(def.iconimage)=="string" and def.iconimage~="" then + if type(def.on_iconclick)=="string" and def.on_iconclick~="" then + modComputing.apps[appname] = { + iconname = def.iconname, + iconimage = def.iconimage, + on_iconclick = def.on_iconclick, + } + return true + else + return false, modComputing.log("modComputing.add_app(appname, def) : Invalid 'def.on_iconclick' variable!") + end + else + return false, modComputing.log("modComputing.add_app(appname, def) : Invalid 'def.iconimage' variable!") + end + else + return false, modComputing.log("modComputing.add_app(appname, def) : Invalid 'def.iconname' variable!") + end + else + return false, modComputing.log("modComputing.add_app(appname, def) : ".. + ("Unable to repeatedly add appname '%s'!"):format(appname) + ) + end + else + return false, modComputing.log("modComputing.add_app(appname, def) : Invalid 'appname' variable!") + end +end + +modComputing.get_appnames = function() + local appnames = [] + for k,v in pairs(modComputing.apps) do + table.insert(appnames, k) + end + return appnames +end + +modComputing.get_app = function(appname) + if type(appname)=="string" and appname~="" then + if type(modComputing.apps[appname])=="table" then + return modComputing.apps[appname] + else + return false, modComputing.log("modComputing.get_app(appname) : ".. + ("Cannot find appname '@1'!"):format(appname) + ) + end + else + return false, modComputing.log("modComputing.get_app(appname) : Invalid 'appname' variable!") + end +end \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..32e49a3 --- /dev/null +++ b/init.lua @@ -0,0 +1,12 @@ +modComputing = { + modname = core.get_current_modname(), + modpath = core.get_modpath(core.get_current_modname()), +} + +--dofile(modComputing.modpath.."/translate.lua") +dofile(modComputing.modpath.."/api.lua") +--dofile(modComputing.modpath.."/item_smartphone.lua") + + + +core.log('action',"[MOD] "..modComputing.modname.." loaded!") diff --git a/item_smartphone.lua b/item_smartphone.lua new file mode 100644 index 0000000..f03ced5 --- /dev/null +++ b/item_smartphone.lua @@ -0,0 +1,15 @@ + + + + +modComputing.show_smartphone = function(playername) + +end + +--[[ +modComputing.add_app("lib_computing:smartphone", { + iconname = "SMARTPHONE", + iconimage = "icon_smartphone.png", + on_iconclick = modComputing.show_smartphone_config, +}) +--]] \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..dd21f9c --- /dev/null +++ b/mod.conf @@ -0,0 +1,2 @@ +name = computing +title = Computing \ No newline at end of file