Document snippets buttons and allow disabling
This commit is contained in:
parent
43d9308c6b
commit
7ce4be4383
16
README.md
16
README.md
@ -4,7 +4,21 @@ A way for admins to run and save lua snippets.
|
|||||||
|
|
||||||
## Chatcommands
|
## Chatcommands
|
||||||
|
|
||||||
- `/snippets`: Open the snippets console.
|
- `/snippets`: Open the snippets console. This allows you to edit and run Lua
|
||||||
|
snippets.
|
||||||
|
|
||||||
|
## Nodes
|
||||||
|
|
||||||
|
This mod registers a snippets button node that runs a snippet when pressed. The
|
||||||
|
snippet will be called with the player name as its first argument. For example,
|
||||||
|
you can do `local name = ...` inside a snippet to get the name of the player
|
||||||
|
that pressed the button.
|
||||||
|
|
||||||
|
Buttons don't appear in the creative inventory, if you want them to you will
|
||||||
|
need to run `/giveme snippets:button`.
|
||||||
|
|
||||||
|
If you don't want the buttons at all, you can add
|
||||||
|
`snippets.enable_buttons = false` to your minetest.conf.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
5
init.lua
5
init.lua
@ -20,4 +20,7 @@ dofile(modpath .. '/forms.lua')
|
|||||||
dofile(modpath .. '/console.lua')
|
dofile(modpath .. '/console.lua')
|
||||||
|
|
||||||
-- Load "snippet buttons"
|
-- Load "snippet buttons"
|
||||||
dofile(modpath .. '/nodes.lua')
|
local enable_buttons = minetest.settings:get_bool('snippets.enable_buttons')
|
||||||
|
if enable_buttons or enable_buttons == nil then
|
||||||
|
dofile(modpath .. '/nodes.lua')
|
||||||
|
end
|
||||||
|
@ -6,7 +6,7 @@ minetest.register_node('snippets:button', {
|
|||||||
description = 'Snippets button',
|
description = 'Snippets button',
|
||||||
tiles = {'default_steel_block.png', 'default_steel_block.png',
|
tiles = {'default_steel_block.png', 'default_steel_block.png',
|
||||||
'default_steel_block.png^snippets_button.png'},
|
'default_steel_block.png^snippets_button.png'},
|
||||||
groups = {cracky = 2},
|
groups = {cracky = 2, not_in_creative_inventory = 1},
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Enables snippets buttons which allow all players to run a specified snippet.
|
||||||
|
snippets.enable_buttons (Register snippets button nodes) bool true
|
Loading…
x
Reference in New Issue
Block a user