diff --git a/README.md b/README.md index 56e841b..fc7ff01 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ You don't need to do any of these presets mentioned below to make this mod work. ## 👄 **Translates:** -See more details in file: [locale/README.md] +See more details in file: [locale/README.md][read_internacionalizaton] ----------------------------------------- @@ -99,44 +99,7 @@ These mods are not mandatory. But, because they are integrated into the 'computi ## 📎 **API of Integration:** -### Syntaxe: - -````lua - modComputing.add_app("", { - icon_name = "", - icon_type = "", --types: button/button_exit - icon_title = "", - icon_descryption = "", - icon_image = "", - on_iconclick = function(clicker) - -- Put here your functions! - end, - }) -```` - -### Sample: - -````lua - if core.global_exists("modComputing") then - modComputing.add_app("my_mod:app_hello_world", { - icon_name = "btnShowAppHelloWorld", - icon_type = "button", - icon_title = "HELLO WORLD", - icon_descryption = "This is a sample of 'hello world' app.", - icon_image = "icon_app.png", - on_iconclick = function(clicker) - local playername = clicker:get_player_name() - core.chat_send_player(playername, - ("The '%s' pressed '%s' button icon app!"):format( - playername, - btnShowAppHelloWorld - ) - ) - -- Put more lines if you want! - end, - }) - end -```` +See more details in file: [docs/API_Integration.md][read_api_integration] ----------------------------------------- @@ -151,7 +114,6 @@ These mods are not mandatory. But, because they are integrated into the 'computi [license_media_icon]:https://img.shields.io/static/v1?label=LICENSE%20MEDIA&message=CC%20BY-SA-4.0&color=yellow [license_media_link]:https://gitlab.com/lunovox/computing/-/raw/main/LICENSE_MEDIA.md -[locale/README.md]:https://gitlab.com/lunovox/computing/-/tree/main/locale?ref_type=heads [computing_icon]:https://gitlab.com/lunovox/computing/-/raw/main/textures/icon_computing.png [luanti_icon]:https://img.shields.io/static/v1?label=Luanti&message=Mod&color=brightgreen [luanti_link]:https://luanti.org @@ -167,6 +129,9 @@ These mods are not mandatory. But, because they are integrated into the 'computi [download_stable]:https://gitlab.com/lunovox/computing/-/tags [download_repository]:https://gitlab.com/lunovox/computing +[read_internacionalizaton]:https://gitlab.com/lunovox/computing/-/tree/main/locale?ref_type=heads +[read_api_integration]:https://gitlab.com/lunovox/computing/-/raw/main/docs/API_Integration.md + [screenshot_general]:https://gitlab.com/lunovox/computing/-/raw/main/screenshot.png [screenshot_recipe_1]:https://gitlab.com/lunovox/computing/-/raw/main/textures/screenshot_recipe_1.png [screenshot_recipe_2]:https://gitlab.com/lunovox/computing/-/raw/main/textures/screenshot_recipe_2.png diff --git a/docs/API_Integration.md b/docs/API_Integration.md new file mode 100644 index 0000000..4185721 --- /dev/null +++ b/docs/API_Integration.md @@ -0,0 +1,111 @@ +# COMPUTING API + +The 'COMPUTING API' provides methods needed for you to create your own 'computing apps' through your own mod. + +------------------------------------------- + +## Show Smartphone Screen + +````lua +modComputing.show_smartphone(player) +```` + +------------------------------------------- + +## Get Smartphone Background FormSpec + +Can you add your own Fields on top of a smartphone background formspec. + +### Syntaxe: + +````lua +modComputing.smartphone.getFormBackground() +```` + +### Sample: Add 'Write your name' field +````lua +local playername = player:get_player_name() +local formspec = "" +..modComputing.smartphone.getFormBackground() +.."field[1.00,2.25;4.5,0.5;txtName;Write your name;"..playername.."]" +core.show_formspec(playername, "formMyModName", formspec) +-- See more methods in: https://github.com/minetest/minetest/blob/master/doc/lua_api.md +```` + +* formspec version = 6 +* formsoec width = 05.6 +* formsoec height = 10.0 + + +------------------------------------------- + +## Adding an App from your Mod + +### Syntaxe: +````lua + modComputing.add_app("", { + icon_name = "", + icon_type = "", --types: button/button_exit + icon_title = "", + icon_descryption = "", + icon_image = "", + is_visible = function(player) + return true + -- The button icon of app only is visible if return true. + end, + on_iconclick = function(clicker) + -- Put here your functions! + end, + }) +```` + +### Sample 1: Hello World +````lua + if core.global_exists("modComputing") then + modComputing.add_app("my_mod:app_hello_world", { + icon_name = "btnShowAppHelloWorld", + icon_type = "button", + icon_title = "HELLO WORLD", + icon_descryption = "This is a sample of 'hello world' app.", + icon_image = "icon_app.png", + on_iconclick = function(clicker) + local playername = clicker:get_player_name() + core.chat_send_player(playername, + ("The '%s' pressed '%s' button icon app!"):format( + playername, + btnShowAppHelloWorld + ) + ) + -- Put more lines if you want! + -- See more methods in: https://github.com/minetest/minetest/blob/master/doc/lua_api.md + end, + }) + end +```` + +### Sample 2: Shut down of server. +````lua + if core.global_exists("modComputing") then + modComputing.add_app("my_mod_app:btnShutdownServer", { + icon_name = "btnShutdownServer", + icon_type = "button_exit", + icon_title = "SHUTDOWN", + icon_descryption = "This is a sample of 'Shutdown Server' app.", + icon_image = "icon_shutdown.png", + is_visible = function(player) + return core.check_player_privs(player, {server = true}) + end, + on_iconclick = function(clicker) + local playername = clicker:get_player_name() + core.request_shutdown( + ("The administrator '%s' has requested that the server be shut down."):format(playername), + false, --If reconnect + 60 --delay in seconds + ) + -- See more methods in: https://github.com/minetest/minetest/blob/master/doc/lua_api.md + end, + }) + end +```` + +------------------------------------------- \ No newline at end of file