[5.0.0] Formspec Theming (minor breaking change)

User avatar
rubenwardy
Moderator
 
Posts: 5499
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

[5.0.0] Formspec Theming (minor breaking change)

by rubenwardy » Tue Aug 14, 2018 12:24

About


Hi, 5.0.0 adds a feature which allows you to prepend a formspec string to every formspec on an opt-out basis. This can be used to theme formspecs - you can make every formspec have the same background and such by default, among other things.

Here is the code used in Minetest Game to set the default theme:

Code: Select all
minetest.register_on_joinplayer(function(player)
   player:set_formspec_prepend([[
         bgcolor[#080808BB;true]
         background[5,5;1,1;gui_formbg.png;true]
         listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]])
end)


Action needed on existing mods


This will cause a minor breaking change in formspecs which don't currently use the default.gui* variables, so you'll either need to accept the consistent background or use the no_prepend[] element to disable the string being prepended to your formspec. You could instead override or modify the string set by Minetest Game's default if you wish it to be game-wide

If you have a node formspec which you'd like to modify to, eg: add no_prepend, then you will need to use an LBM:

Code: Select all
minetest.register_lbm({
   name = "mymod:formspecfix",
   nodenames = { "mymod:node" },
   action = function(pos, node)
      local meta = minetest.get_meta(pos)
      meta:set_string("formspec", mymod.get_formspec())
   end,
})


See lua_api.txt for more documentation
 

User avatar
Wuzzy
Member
 
Posts: 3232
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [5.0.0] Formspec Theming using Prepended Strings

by Wuzzy » Tue Aug 14, 2018 14:38

Awesome! This was much needed.
This will make formspec theming a piece of cake and hopefully the number of ugly default-themed formspecs will go down drastically.
My creations. I gladly take any bitcoins you have lying around: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
v-rob
Member
 
Posts: 559
Joined: Thu Mar 24, 2016 03:19
Location: Right behind you.
GitHub: v-rob

Re: [5.0.0] Formspec Theming using Prepended Strings

by v-rob » Tue Aug 14, 2018 16:20

Didn't this already exist? I thought I recalled seeing it somewhere. But regardless, this is awesome! Can this be used to remove the default gui things? I prefer the plain formspecs.
 

User avatar
rubenwardy
Moderator
 
Posts: 5499
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: [5.0.0] Formspec Theming using Prepended Strings

by rubenwardy » Tue Aug 14, 2018 16:26

v-rob wrote:Didn't this already exist? I thought I recalled seeing it somewhere.


This was added quite a few months ago, I've only just made an announcement

v-rob wrote:Can this be used to remove the default gui things? I prefer the plain formspecs.


Sure! You can make a mod to remove the background and just have a bgcolor with this feature.
 

User avatar
v-rob
Member
 
Posts: 559
Joined: Thu Mar 24, 2016 03:19
Location: Right behind you.
GitHub: v-rob

Re: [5.0.0] Formspec Theming (minor breaking change)

by v-rob » Wed Aug 15, 2018 00:00

Wow! This is great! This is going to be a very useful feature.
 


Return to News



Who is online

Users browsing this forum: No registered users and 5 guests