From 7d4eef0da3c40af121c847434f5c99465ccf2cc1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 3 Aug 2016 00:20:26 +0200 Subject: Add text template for build_formspec param --- API.md | 8 ++++++++ init.lua | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/API.md b/API.md index 08220b7..e14f039 100644 --- a/API.md +++ b/API.md @@ -53,6 +53,14 @@ data. only parameter (has the data type of the entry data) and must return a formspec which is inserted in the Entry tab. +#### Predefined values `build_formspec` +For `build_formspec` you can either define your own function or use one +of the following predefined functions: + +* `doc.entry_templates.text`: Expects entry data to be a string. + It will be inserted directly into the entry. Use “`\n`” to start a + new line. + #### Return value Always `nil`. diff --git a/init.lua b/init.lua index 085411d..2ea8a40 100644 --- a/init.lua +++ b/init.lua @@ -146,6 +146,14 @@ function doc.get_viewed_count(playername, category_id) end end +-- Template function templates, to be used for build_formspec in doc.new_category +doc.entry_templates = {} + +-- Freeform text +doc.entry_templates.text = function(data) + return "textarea[0.25,0.5;11,8;;"..minetest.formspec_escape(data)..";]" +end + --[[ Functions for internal use ]] function doc.formspec_core(tab) -- cgit v1.2.3