mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-06-28 06:11:47 +02:00
- Delete useless files/mods
- Add builtin_falling (by Davedevils) for an amazing bugfix - Tweak node.lua from the subgame MFF and « sea » mod for builtin_falling - Remove news.lua from _misc - Remove _misc_me (empty now) - Add a new mod named « news » and tweak this mod, it works now, add texture for the news (Thank you Davedevils)
This commit is contained in:
53
mods/news/init.lua
Normal file
53
mods/news/init.lua
Normal file
@ -0,0 +1,53 @@
|
||||
local news = {}
|
||||
|
||||
local path = minetest.get_worldpath()
|
||||
|
||||
local function formspec(player,article)
|
||||
|
||||
--if ( article == "" or article == nil ) then
|
||||
article = "news.txt" -- vu qu'il s'en sert pas
|
||||
--else
|
||||
-- article = "news_"..article..".txt"
|
||||
--end
|
||||
|
||||
local newsfile = io.open(path.."/"..article,"r")
|
||||
|
||||
local formspec = "size[12,10;]"
|
||||
formspec = formspec.."background[-0.22,-0.25;13,11;background.jpg]"
|
||||
|
||||
if newsfile ~= nil then
|
||||
local newscontent = newsfile:read("*a")
|
||||
formspec = formspec.."textarea[.50,.50;12,10;news;;"..minetest.formspec_escape(newscontent).."]"
|
||||
else
|
||||
formspec = formspec.."label[.50,.50;Pas d'article pour le moment]"
|
||||
end
|
||||
formspec = formspec.."button_exit[5,9.25;2,1;exit;Fermer"
|
||||
if ( newsfile ~= nil ) then
|
||||
newsfile:close()
|
||||
end
|
||||
return formspec
|
||||
end
|
||||
|
||||
local function show_formspec(player)
|
||||
local name = player:get_player_name()
|
||||
minetest.show_formspec(name,"news",formspec(player))
|
||||
minetest.log('action','Showing formspec to '..name)
|
||||
end
|
||||
|
||||
|
||||
minetest.register_chatcommand("news",{
|
||||
params = "<article>",
|
||||
description="Montre les news du serveur",
|
||||
func = function (name,params)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
minetest.show_formspec(name,"news",formspec(player,params))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function (player)
|
||||
minetest.after(6,show_formspec,player)
|
||||
end)
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
minetest.after(8,show_formspec,player)
|
||||
end)
|
BIN
mods/news/textures/background.jpg
Normal file
BIN
mods/news/textures/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 201 KiB |
Reference in New Issue
Block a user