Extend signs_lib to support texts stored in code rather than being specified in-world.
Download at https://github.com/eidy/dynamicsigns/archive/master.zip
A signid is assigned against the sign, which is used to lookup the text rather than it being specified in-world all the time.
It works for all the signs defined in signs_lib.
Example Usage
Register internationalised text using intllib:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
dynamicsigns.register("traveltokapiti",S('Travel to Kapiti'))
Register a function call to look up text:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
dynamicsigns.register("thetime",function() return "Game Time : " .. (minetest.get_timeofday() * 24000) end)
Automatically update a "signs.lua" file with texts that can be localised
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
dynamicsigns.registermod("eidytext")
Depends: default, signs_lib
Code license: Apache 2.0
Github: https://github.com/eidy/dynamicsigns
Dynamic Signs API
dynamicsigns.register(signid, text)
Register a text to be shown on a sign
dynamicsigns.register(signid, function)
Register a function to be invoked to get the text to be shown on a sign
dynamicsigns.registermod(modname)
Registers a mod, that will contain an automatically updated file called "signs.lua" that will be used to store sign texts.
This override the default "signs_lib" dialog functionality.
How to localise signs
1. Copy in your favourite mod internationalisation library
(I like intllib - viewtopic.php?id=4929)
2. Register your ids
3. Create signs in your game world, then use the popup or the "/setsign" command to set the signid
(Requires server privilege)
How to setup an automatically updated signs file
1. Make a mod to store your sign texts (eg "eidytext")
2. Create a depends.txt that looks like this:
default
dynamicsigns
3. Create an init.lua that looks like this:
dynamicsigns.registermod("eidytext")
dofile(minetest.get_modpath("eidytext").."/signs.lua");
4. Use the chat commands or the right mouse button to set your sign texts, setting the sign id with a prefix corresponding to your mod name. eg "eidytextwelcome"
This will automatically create a "signs.lua" file like containing text like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Generated by dynamicsigns
local S;
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua");
S = intllib.Getter("eidytext");
else
S = function ( s ) return s end;
end
dynamicsigns.register("eidytextwelcome",S("Welcome to my amazing educational game!"))
dynamicsigns.register("eidytextkapiti",S("I love going to the big city"))
Chat Commands
/setsign signid
Set the nearest sign to update automatically using the specified signid
Admin required
(If the signid isn't found, the sign content will be set to the signid value)
/setsign
Clear the current signid - Goes back to working like a normal sign
/showsign
Dump the contents of the sign metadata to the console
Thanks
Big thanks to VanessaE (obviously) for supporting signs_lib