added locales

master
Sokomine 2019-06-02 19:34:34 +02:00
parent aa59e2c603
commit 5b826bc3bd
14 changed files with 645 additions and 35 deletions

View File

@ -11,6 +11,9 @@
-- guests Negative value, i.e. -2: 2 of the beds will belong to the family working here; the rest will be guests.
-- For building type "chateau", guest names the number of servants/housemaids instead of guests.
-- Intllib
local S = mg_villages.intllib
mg_villages.all_buildings_list = {}
local buildings = {
@ -294,7 +297,7 @@ mg_villages.add_building = function( building_data )
if( not( is_used )) then
-- do nothing; skip this file
mg_villages.print(mg_villages.DEBUG_LEVEL_INFO, 'SKIPPING '..tostring( building_data.scm )..' due to village type not supported.');
mg_villages.print(mg_villages.DEBUG_LEVEL_INFO, S("SKIPPING").." "..tostring( building_data.scm )..' '..S("due to village type not supported."));
-- building cannot be used
building_data.not_available = 1;
return false;
@ -307,7 +310,7 @@ mg_villages.add_building = function( building_data )
local res = handle_schematics.analyze_file( file_name, building_data.we_origin, building_data.mts_path .. building_data.scm, building_data, true );
if( not( res )) then
mg_villages.print(mg_villages.DEBUG_LEVEL_WARNING, 'SKIPPING '..tostring( building_data.scm )..' due to import failure.');
mg_villages.print(mg_villages.DEBUG_LEVEL_WARNING, S("SKIPPING").." "..tostring( building_data.scm ).." "..S("due to import failure."));
building_data.not_available = 1;
return false;
-- provided the file could be analyzed successfully (now covers both .mts and .we files)
@ -322,7 +325,7 @@ mg_villages.add_building = function( building_data )
or building_data.sizex == 0 or building_data.sizez==0) then
-- no village will use it
mg_villages.print( mg_villages.DEBUG_LEVEL_INFO, 'No schematic found for building \''..tostring( building_data.scm )..'\'. Will not use that building.');
mg_villages.print( mg_villages.DEBUG_LEVEL_INFO, S("No schematic found for building").." \'"..tostring( building_data.scm ).."\'. "..S("Will not use that building."));
building_data.weight = {};
building_data.not_available = 1;
return false;
@ -334,7 +337,7 @@ mg_villages.add_building = function( building_data )
if( not( building_data.weight ) or type( building_data.weight ) ~= 'table' ) then
mg_villages.print( mg_villages.DEBUG_LEVEL_WARNING, 'SKIPPING '..tostring( building_data.scm )..' due to missing weight information.');
mg_villages.print( mg_villages.DEBUG_LEVEL_WARNING, S("SKIPPING").." "..tostring( building_data.scm ).." "..S("due to missing weight information."));
building_data.not_available = 1;
return false;
end

View File

@ -1,5 +1,7 @@
-- Intllib
local S = mg_villages.intllib
minetest.register_privilege("mg_villages", { description = "Allows to teleport to villages via /vist <nr>", give_to_singleplayer = false});
minetest.register_privilege("mg_villages", { description = S("Allows to teleport to villages via").." /vist <nr>", give_to_singleplayer = false});
-- store per player which list of villages was offered
mg_villages.tmp_player_village_list = {};
@ -194,7 +196,7 @@ end
minetest.register_chatcommand( 'villages', {
description = "Shows a list of all known villages.",
description = S("Shows a list of all known villages."),
privs = {},
func = function(name, param)
mg_villages.list_villages_formspec( minetest.get_player_by_name( name ), "mg_villages:formspec_list_villages", {});
@ -203,19 +205,19 @@ minetest.register_chatcommand( 'villages', {
minetest.register_chatcommand( 'visit', {
description = "Teleports you to a known village.",
description = S("Teleports you to a known village."),
params = "<village number>",
privs = {},
func = function(name, param)
if( mg_villages.REQUIRE_PRIV_FOR_TELEPORT and not( minetest.check_player_privs( name, {mg_villages=true}))) then
minetest.chat_send_player( name, "You need the 'mg_villages' priv in order to teleport to villages using this command.");
minetest.chat_send_player( name, S("You need the 'mg_villages' priv in order to teleport to villages using this command."));
return;
end
if( not( param ) or param == "" ) then
minetest.chat_send_player( name, "Which village do you want to visit? Please provide the village number!");
minetest.chat_send_player( name, S("Which village do you want to visit? Please provide the village number!"));
return;
end
@ -224,7 +226,7 @@ minetest.register_chatcommand( 'visit', {
-- we have found the village
if( v and v.nr == nr ) then
minetest.chat_send_player( name, "Initiating transfer to village no. "..tostring( v.nr )..", called "..( tostring( v.name or 'unknown'))..".");
minetest.chat_send_player( name, S("Initiating transfer to village no.")..' '..tostring( v.nr )..", "..S("called ")..( tostring( v.name or 'unknown'))..".");
local player = minetest.get_player_by_name( name );
player:move_to( { x=v.vx, y=(v.vh+1), z=v.vz }, false);
return;
@ -274,6 +276,6 @@ minetest.register_chatcommand( 'village_mob_repopulate', {
end
end
-- no village found
minetest.chat_send_player( name, "There is no village with the number "..tostring( param ).." (yet?).");
minetest.chat_send_player( name, S("There is no village with the number")..' '..tostring( param ).." ("..S("yet").."?)");
end
});

View File

@ -20,5 +20,6 @@ grounds?
moreblocks?
bell?
mg?
intllib?
mob_world_interaction?
cavestuff?

View File

@ -1,12 +1,20 @@
-- reserve namespace for the villages
mg_villages = {}
-- Intllib
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
mg_villages.intllib = S
mg_villages.all_villages = {}
mg_villages.mg_generated_map = {}
mg_villages.anz_villages = 0;
mg_villages.modpath = minetest.get_modpath( "mg_villages");
mg_villages.modpath = minetest.get_modpath("mg_villages");
mg_villages.DEBUG_LEVEL_NONE = -1 -- -1: disable all printed messages

View File

@ -1,3 +1,6 @@
-- Intllib
local S = mg_villages.intllib
-- this functions needs to be called once after *all* village types and buildings have been added
mg_villages.init_weights = function()
@ -8,7 +11,7 @@ mg_villages.init_weights = function()
table.insert( mg_villages.village_types, k );
end
end
mg_villages.print(mg_villages.DEBUG_LEVEL_NORMAL,'Will create villages of the following types: '..minetest.serialize( mg_villages.village_types ));
mg_villages.print(mg_villages.DEBUG_LEVEL_NORMAL,S("Will create villages of the following types").." : "..minetest.serialize( mg_villages.village_types ));

91
locale/fr.txt Normal file
View File

@ -0,0 +1,91 @@
SKIPPING = IGNORE
Error: Village type = Erreur : le type de village
lacks size information. = l'information 'size' est manquante.
due to village type not supported. = car le type de village n'est pas supporté.
due to import failure. = car l'importation a echoué
No schematic found for building = Pas de schéma pour ce batiment
Will not use that building. = Ce batiment ne sera pas utilisé.
due to missing weight information. = car l'information 'weight' est manquante.
Allows to teleport to villages via = Permet de se téléporter dans les villages via la commande
Shows a list of all known villages. = Affiche une liste des villages connus.
Teleports you to a known village. = Vous téléporte dans un village connu.
You need the 'mg_villages' priv in order to teleport to villages using this command. = Vous devez avoir le privilège 'mg_village' pour utiliser cette commande.
Which village do you want to visit? Please provide the village number! = Quel village souhaitez-vous visiter ? Renseignez le numero du village s'il vous plait !
Initiating transfer to village no. = Debut du tranfert vers le village no.
called = applellé
There is no village with the number = Il n'y a pas de village portant le numéro
yet = pas encore
Will create villages of the following types = Les types de villages suivants seront crées
CHANGING HEIGHT from = CHANGE LA HAUTEUR depuis
to = vers
TIME ELAPSED = TEMPS ECOULE
Villages shown on this map = Villages montrés sur cette carte
Shows a map of all known villages withhin = Affiche une carte des villages connus dans un rayon de
blocks. = blocs.
Abandoned building = Batiment abandonné
House = Maison
village road = route de village
Soil found on a field = Terre labourée dans un champ
Desert Sand = Sable du Désert
Torch = Torche
Plot marker = Balise de parcelle
Lava Source (tame) = Source de lave (inoffensive)
Flowing Lava (tame) = Lave coulante (inoffensive)
Error: This area does not belong to a village. = Erreur: Cettre zone n'appartient pas a un village.
You are inside of the area of the village = Cette zone appartient fait partie du village de
. The inhabitants do not allow you any modifications. = . Les habitants n'autorisent pas les modifications.
Error. This plot marker is not configured correctly. = Erreur. Cette balise de parcelle n'est pas correctement configurée.
the village community = la municipalité
for sale = a vendre
Plot No. = Emplacement No.
Located at = Situé a
Part of village = Dans le village
, which is = , soit a
m away = m de distance
from the village center = du centre du village
name unknown = nom inconnu
Owned by = Appartient a
owned by = appartient a
Click on a menu entry to select it = Cliquez sur une entrée du menu pour la séléctionner
Some traders live here. One works as a = Des marchands vivent ici. L'un exerce le metier de
Another trader works as a = Un autre travaille en tant que
A trader lives here. He works as a = Un marchand vit ici. Il exerce le metier de
No trader currently works at this place. = Aucun marchand ne vit ici
You are visiting the = Vous rendez visite au marchand de
trader, who is supposed to be somewhere here. He might also be on a floor above you. = , il devrait se trouver dans les parages. Il peut aussi être à l'étage au dessus de vous.
Back = Retour
You need the 'protection_bypass' priv in order to use this function. = Vous avez besoin du privilège 'protection_bypass' pour utliser cette fonction.
The plot has been cleared. = L'emplacement à été vidé.
The building has been reset. = Le batiment a été réinitialisé.
Change materials used = Changer les materiaux utilisés
Show materials used = Afficher les materiaux utilisés
Create backup of current stage = Copie de sauvegarde de l'etat actuel
Reset building = Réinitaliser le batiment
Remove building = Raser le batiment
Unsupported village type = Type de village non supporté
for house at = pour la maison située a
adding SINGLE HOUSE of type = ajout d'une MAISON ISOLEE du type
to map at = a la position
Error: Village type = Erreur : Village type
Sorry. You already have a plot in this village. = Désolé. Vous possedez déjà un emplacement dans ce village.
Congratulations! You have bought this plot. = Félicitations ! Vous avez acheté cette parcelle.
with = avec
Owners of this plot count as village inhabitants. = Le proprietaire de cet emplacement est considéré comme habitant.
Sorry. You are not able to pay the price. = Désolé. Vous n'avez pas les matériaux requis.
You are allowed to modify the common village area. = Vous etes autorisé a modifier les espaces publics de ce village.
This is your plot. You have bought it. = Vous avez acheté cette parcelle.
Add/Remove Players = Ajouter/Enlever des joueurs
Abandon plot = Abandonner
You have abandoned this plot. = Vous avez abandonné cette parcelle.
Trusted Players = Joueurs Autorisés
Save = Enregistrer
owns this plot = a acheté cette parcelle
You can buy this plot for = Vous pouvez acheter cette parcelle pour
Building = Batiment
Buy plot = Acheter
Info = Info
Exit = Quitter
Hire a new random trader = Engager un nouveau vendeur aléatoire
visit = Rendre visite
call = Appeller
fire = Congédier

91
locale/template.txt Normal file
View File

@ -0,0 +1,91 @@
SKIPPING =
Error: Village type =
lacks size information. =
due to village type not supported. =
due to import failure. =
No schematic found for building =
Will not use that building. =
due to missing weight information. =
Allows to teleport to villages via =
Shows a list of all known villages. =
Teleports you to a known village. =
You need the 'mg_villages' priv in order to teleport to villages using this command. =
Which village do you want to visit? Please provide the village number! =
Initiating transfer to village no. =
called =
There is no village with the number =
yet =
Will create villages of the following types =
CHANGING HEIGHT from =
to =
TIME ELAPSED =
Villages shown on this map =
Shows a map of all known villages withhin =
blocks. =
Abandoned building =
House =
village road =
Soil found on a field =
Desert Sand =
Torch =
Plot marker =
Lava Source (tame) =
Flowing Lava (tame) =
Error: This area does not belong to a village. =
You are inside of the area of the village =
. The inhabitants do not allow you any modifications. =
Error. This plot marker is not configured correctly. =
the village community =
for sale =
Plot No. =
Located at =
Part of village =
, which is =
m away =
from the village center =
name unknown =
Owned by =
owned by =
Click on a menu entry to select it =
Some traders live here. One works as a =
Another trader works as a =
A trader lives here. He works as a =
No trader currently works at this place. =
You are visiting the =
trader, who is supposed to be somewhere here. He might also be on a floor above you. =
Back =
You need the 'protection_bypass' priv in order to use this function. =
The plot has been cleared. =
The building has been reset. =
Change materials used =
Show materials used =
Create backup of current stage =
Reset building =
Remove building =
Unsupported village type =
for house at =
adding SINGLE HOUSE of type =
to map at =
Error: Village type =
Sorry. You already have a plot in this village. =
Congratulations! You have bought this plot. =
with =
Owners of this plot count as village inhabitants. =
Sorry. You are not able to pay the price. =
You are allowed to modify the common village area. =
This is your plot. You have bought it. =
Add/Remove Players =
Abandon plot =
You have abandoned this plot. =
Trusted Players =
Save =
owns this plot =
You can buy this plot for =
Building =
Buy plot =
Info =
Exit =
Hire a new random trader =
visit =
call =
fire =

View File

@ -1,4 +1,5 @@
-- Intllib
local S = mg_villages.intllib
-- villages up to this many nodes in each direction are shown on the map
mg_villages.MAP_RANGE = 1000;
@ -169,7 +170,7 @@ mg_villages.map_of_world = function( pname )
end
i = i+0.45;
formspec = formspec.."label[10.0,"..tostring(i)..";Villages shown on this map:]";
formspec = formspec.."label[10.0,"..tostring(i)..";"..S("Villages shown on this map").." : ]";
i = i+0.45;
local j = 1;
while (i<10.5 and j<=#shown_villages) do
@ -184,7 +185,7 @@ end
minetest.register_chatcommand( 'vmap', {
description = "Shows a map of all known villages withhin "..tostring( mg_villages.MAP_RANGE ).." blocks.",
description = S("Shows a map of all known villages withhin")..' '..tostring( mg_villages.MAP_RANGE )..' '..S("blocks."),
privs = {},
func = function(name, param)
minetest.show_formspec( name, 'mg:world_map', mg_villages.map_of_world( name ));

View File

@ -1,3 +1,5 @@
-- Intllib
local S = mg_villages.intllib
------------------------------------------------------------------------------
-- Interface for other mods
@ -772,7 +774,7 @@ end
mg_villages.change_village_height = function( village, new_height )
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, 'CHANGING HEIGHT from '..tostring( village.vh )..' to '..tostring( new_height ));
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, S("CHANGING HEIGHT from").." "..tostring( village.vh ).." "..S("to").." "..tostring( new_height ));
for _, pos in ipairs(village.to_add_data.bpos) do
pos.y = new_height;
end
@ -974,7 +976,7 @@ end
time_elapsed = function( t_last, msg )
mg_villages.t_now = minetest.get_us_time();
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, 'TIME ELAPSED: '..tostring( mg_villages.t_now - t_last )..' '..msg );
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, S("TIME ELAPSED").." : "..tostring( mg_villages.t_now - t_last )..' '..msg );
return mg_villages.t_now;
end

View File

@ -1,3 +1,5 @@
-- Intllib
local S = mg_villages.intllib
namegen = {};
@ -76,14 +78,14 @@ namegen.generate_village_name_with_prefix = function( pr, village )
if( village.is_single_house and village.to_add_data and village.to_add_data.bpos ) then
-- the building got removed from mg_villages.BUILDINGS in the meantime
if( not( mg_villages.BUILDINGS[ village.to_add_data.bpos[1].btype] )) then
return 'Abandomed building';
return S("Abandoned building");
end
local btyp = mg_villages.BUILDINGS[ village.to_add_data.bpos[1].btype].typ;
local bdata = mg_villages.village_type_data[ btyp ];
if( bdata and (bdata.name_prefix or bdata.name_postfix )) then
name = (bdata.name_prefix or '')..name..(bdata.name_postfix or '');
else
name = 'House '..name;
name = S("House")..' '..name;
end
end
return name;

View File

@ -1,7 +1,9 @@
-- Intllib
local S = mg_villages.intllib
-- slightly lower than a normal nodes for better look
minetest.register_node("mg_villages:road", {
description = "village road",
description = S("village road"),
tiles = {"default_gravel.png", "default_dirt.png"},
is_ground_content = false, -- will not be removed by the cave generator
groups = {crumbly=2}, -- does not fall
@ -28,7 +30,7 @@ end
-- special soil that does not need abms/lbms or water
minetest.register_node("mg_villages:soil", {
description = "Soil found on a field",
description = S("Soil found on a field"),
tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png"},
drop = "default:dirt",
is_ground_content = true,
@ -37,7 +39,7 @@ minetest.register_node("mg_villages:soil", {
})
minetest.register_node("mg_villages:desert_sand_soil", {
description = "Desert Sand",
description = S("Desert Sand"),
tiles = {"default_desert_sand.png^farming_soil_wet.png", "default_desert_sand.png"},
is_ground_content = true,
drop = "default:desert_sand",
@ -50,7 +52,7 @@ minetest.register_node("mg_villages:desert_sand_soil", {
if( mg_villages.USE_DEFAULT_3D_TORCHES == false ) then
-- This torch is not hot. It will not melt snow and cause no floodings in villages.
minetest.register_node("mg_villages:torch", {
description = "Torch",
description = S("Torch"),
drawtype = "torchlike",
--tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
tiles = {
@ -82,7 +84,7 @@ end
-- get information about a plot, the building, its inhabitants; allow to buy the plot etc.
minetest.register_node("mg_villages:plotmarker", {
description = "Plot marker",
description = S("Plot marker"),
drawtype = "nodebox",
tiles = {"default_stone_brick.png"},
is_ground_content = false,
@ -157,7 +159,7 @@ if( not( mg_villages.use_normal_unsafe_lava )) then
new_def.groups.hot = nil;
new_def.groups.igniter = nil;
new_def.groups.lava_tamed = 3;
new_def.description = "Lava Source (tame)";
new_def.description = S("Lava Source (tame)");
new_def.liquid_alternative_flowing = "mg_villages:lava_flowing_tamed";
new_def.liquid_alternative_source = "mg_villages:lava_source_tamed";
-- we create a NEW type of lava for this
@ -175,7 +177,7 @@ if( not( mg_villages.use_normal_unsafe_lava )) then
new_def.groups.hot = nil;
new_def.groups.igniter = nil;
new_def.groups.lava_tamed = 3;
new_def.description = "Flowing Lava (tame)";
new_def.description = S("Flowing Lava (tame)");
new_def.liquid_alternative_flowing = "mg_villages:lava_flowing_tamed";
new_def.liquid_alternative_source = "mg_villages:lava_source_tamed";
-- and a NEW type of flowing lava...

View File

@ -1,3 +1,6 @@
-- Intllib
local S = mg_villages.intllib
-- get the id of the village pos lies in (or nil if outside of villages)
mg_villages.get_town_id_at_pos = function( pos )
for id, v in pairs( mg_villages.all_villages ) do
@ -153,11 +156,406 @@ minetest.register_on_protection_violation( function(pos, name)
local found = mg_villages.get_town_id_at_pos( pos );
if( not( found ) or not( mg_villages.all_villages[ found ])) then
minetest.chat_send_player( name, 'Error: This area does not belong to a village.');
minetest.chat_send_player( name, S("Error: This area does not belong to a village."));
return;
end
minetest.chat_send_player( name, "You are inside of the area of the village "..
minetest.chat_send_player( name, S("You are inside of the area of the village").." "..
tostring( mg_villages.all_villages[ found ].name )..
". The inhabitants do not allow you any modifications.");
S(". The inhabitants do not allow you any modifications."));
end );
mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
-- if( not( mg_villages.ENABLE_PROTECTION )) then
-- return;
-- end
local meta = minetest.get_meta( pos );
if( not( meta )) then
return;
end
local village_id = meta:get_string('village_id');
local plot_nr = meta:get_int( 'plot_nr');
local pname = player:get_player_name();
if( not( village_id )
or not( mg_villages.all_villages )
or not( mg_villages.all_villages[ village_id ] )
or not( plot_nr )
or not( mg_villages.all_villages[ village_id ].to_add_data )
or not( mg_villages.all_villages[ village_id ].to_add_data.bpos )
or not( mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ] )) then
minetest.chat_send_player( pname, S("Error. This plot marker is not configured correctly.")..minetest.serialize({village_id,plot_nr }));
return;
end
local village = mg_villages.all_villages[ village_id ];
local plot = mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ];
local owner_name = plot.owner;
if( not( owner_name ) or owner_name == "" ) then
if( plot.btype=="road" ) then
owner_name = " - "..S("the village community").." - ";
else
owner_name = " - "..S("for sale").." - ";
end
end
local building_name = mg_villages.BUILDINGS[ plot.btype ].mts_path..mg_villages.BUILDINGS[ plot.btype ].scm;
-- show coordinates of the village center to the player
local village_pos = minetest.pos_to_string( {x=village.vx, y=village.vh, z=village.vz});
-- distance from village center
local distance = math.floor( math.sqrt( (village.vx - pos.x ) * (village.vx - pos.x )
+ (village.vh - pos.y ) * (village.vh - pos.y )
+ (village.vz - pos.z ) * (village.vz - pos.z ) ));
-- create the header
local formspec = "size[13,10]"..
"label[3.3,0.0;"..S("Plot No.").." : "..tostring( plot_nr )..", "..S("with")..' '..tostring( mg_villages.BUILDINGS[ plot.btype ].scm ).."]"..
"label[0.3,0.4;"..S("Located at").." : ]" .."label[3.3,0.4;"..(minetest.pos_to_string( pos ) or '?')..S(", which is")..' '..tostring( distance )..' '..S("m away").."]"
.."label[7.3,0.4;"..S("from the village center").."]"..
"label[0.3,0.8;"..S("Part of village").." :]" .."label[3.3,0.8;"..(village.name or " - "..S("name unknown")).." - ".."]"
.."label[7.3,0.8;"..S("Located at").." : "..(village_pos).."]"..
"label[0.3,1.2;"..S("Owned by").." : ]" .."label[3.3,1.2;"..(owner_name).."]"..
"label[3.3,1.6;"..S("Click on a menu entry to select it").." : ]"..
"field[20,20;0.1,0.1;pos2str;Pos;"..minetest.pos_to_string( pos ).."]";
build_chest.show_size_data( building_name );
if( plot and plot.traders ) then
if( #plot.traders > 1 ) then
formspec = formspec.."label[0.3,7.0;"..S("Some traders live here. One works as a")..' '..tostring(plot.traders[1].typ)..".]";
for i=2,#plot.traders do
formspec = formspec.."label[0.3,"..(6.0+i).."; "..S("Another trader works as a")..' '..tostring(plot.traders[i].typ)..".]";
end
elseif( plot.traders[1] and plot.traders[1].typ) then
formspec = formspec..
"label[0.3,7.0;"..S("A trader lives here. He works as a")..' '..tostring( plot.traders[1].typ )..".]";
else
formspec = formspec..
"label[0.3,7.0;"..S("No trader currently works at this place.").."]";
end
-- add buttons for visiting (teleport to trader), calling (teleporting trader to plot) and firing the trader
for i,trader in ipairs(plot.traders) do
local trader_entity = mg_villages.plotmarker_search_trader( trader, village.vh );
formspec = formspec..
"button[6.0,"..(6.0+i)..";1.2,0.5;visit_trader_"..i..";"..S("visit").."]"..
"button[7.4,"..(6.0+i)..";1.2,0.5;call_trader_"..i..";"..S("call").."]"..
"button[8.8,"..(6.0+i)..";1.2,0.5;fire_trader_"..i..";"..S("fire").."]";
if( fields[ "visit_trader_"..i ] ) then
player:moveto( {x=trader.x, y=(village.vh+1), z=trader.z} );
minetest.chat_send_player( pname, S("You are visiting the")..' '..tostring( trader.typ )..' '..
S("trader, who is supposed to be somewhere here. He might also be on a floor above you."));
return;
end
if( fields[ "visit_call_"..i ] ) then
-- TODO: spawning: mob_basics.spawn_mob( {x=v.x, y=v.y, z=v.z}, v.typ, nil, nil, nil, nil, true );
end
-- TODO: fire mob
end
formspec = formspec.."button[3.75,"..(7.0+math.max(1,#plot.traders))..";3.5,0.5;hire_trader;"..S("Hire a new random trader").."]";
-- TODO: hire mob
end
local replace_row = -1;
-- the player selected a material which ought to be replaced
if( fields.build_chest_replacements ) then
local event = minetest.explode_table_event( fields.build_chest_replacements );
if( event and event.row and event.row > 0 ) then
replace_row = event.row;
fields.show_materials = "show_materials";
end
-- the player provided the name of the material for the replacement of the currently selected
elseif( fields.store_replacement and fields.store_repalcement ~= ""
and fields.replace_row_with and fields.replace_row_with ~= ""
and fields.replace_row_material and fields.replace_row_material ~= "") then
build_chest.replacements_apply( pos, meta, fields.replace_row_material, fields.replace_row_with, village_id );
fields.show_materials = "show_materials";
-- group selections for easily changing several nodes at once
elseif( fields.wood_selection ) then
build_chest.replacements_apply_for_group( pos, meta, 'wood', fields.wood_selection, fields.set_wood, village_id );
fields.set_wood = nil;
fields.show_materials = "show_materials";
elseif( fields.farming_selection ) then
build_chest.replacements_apply_for_group( pos, meta, 'farming', fields.farming_selection, fields.set_farming, village_id );
fields.set_farming = nil;
fields.show_materials = "show_materials";
elseif( fields.roof_selection ) then
build_chest.replacements_apply_for_group( pos, meta, 'roof', fields.roof_selection, fields.set_roof, village_id );
fields.set_roof = nil;
fields.show_materials = "show_materials";
-- actually store the new group replacement
elseif( (fields.set_wood and fields.set_wood ~= "")
or (fields.set_farming and fields.set_farming ~= "" )
or (fields.set_roof and fields.set_roof ~= "" )) then
minetest.show_formspec( pname, "mg_villages:plotmarker",
handle_schematics.get_formspec_group_replacement( pos, fields, formspec ));
return;
end
-- show which materials (and replacements!) where used for the building
if( (fields.show_materials and fields.show_materials ~= "" )
or (fields.replace_row_with and fields.replace_row_with ~= "")
or (fields.replace_row_material and fields.replace_row_material ~= "")) then
formspec = formspec.."button[9.9,0.4;2,0.5;info;"..S("Back").."]";
if( not( minetest.check_player_privs( pname, {protection_bypass=true}))) then
-- do not allow any changes; just show the materials and their replacements
minetest.show_formspec( pname, "mg_villages:plotmarker",
formspec..build_chest.replacements_get_list_formspec( pos, nil, 0, meta, village_id, building_name, replace_row ));
else
minetest.show_formspec( pname, "mg_villages:plotmarker",
formspec..build_chest.replacements_get_list_formspec( pos, nil, 1, nil, village_id, building_name, replace_row ));
end
return;
-- place the building again
elseif( (fields.reset_building and fields.reset_building ~= "")
or (fields.remove_building and fields.remove_building ~= "")) then
formspec = formspec.."button[9.9,0.4;2,0.5;back;"..S("Back").."]";
if( not( minetest.check_player_privs( pname, {protection_bypass=true}))) then
minetest.show_formspec( pname, "mg_villages:plotmarker", formspec..
"label[3,3;"..S("You need the 'protection_bypass' priv in order to use this function.").."]"
);
return;
end
local selected_building = build_chest.building[ building_name ];
local start_pos = {x=plot.x, y=plot.y, z=plot.z, brotate=plot.brotate};
if( selected_building.yoff ) then
start_pos.y = start_pos.y + selected_building.yoff;
end
local end_pos = {x=plot.x+plot.bsizex-1,
y=plot.y+selected_building.yoff-1+selected_building.ysize,
z=plot.z+plot.bsizez-1};
local replacements = build_chest.replacements_get_current( meta, village_id );
if( fields.remove_building and fields.remove_building ~= "" ) then
-- clear the space above ground, put dirt below ground, but keep the
-- surface intact
handle_schematics.clear_area( start_pos, end_pos, pos.y-1);
-- also clear the meta data to avoid strange effects
handle_schematics.clear_meta( start_pos, end_pos );
formspec = formspec.."label[3,3;"..S("The plot has been cleared.").."]";
else
-- actually place it (disregarding mirroring)
local error_msg = handle_schematics.place_building_from_file(
start_pos,
end_pos,
building_name,
replacements,
plot.o,
build_chest.building[ building_name ].axis, plot.mirror, 1, true );
formspec = formspec.."label[3,3;"..S("The building has been reset.").."]";
if( error_msg ) then
formspec = formspec..'label[4,3;Error: '..tostring( fields.error_msg ).."]";
end
end
minetest.show_formspec( pname, "mg_villages:plotmarker", formspec );
return;
elseif( fields.info and fields.info ~= "" ) then
local show_material_text = S("Change materials used");
if( not( minetest.check_player_privs( pname, {protection_bypass=true}))) then
show_material_text = S("Show materials used");
end
minetest.show_formspec( pname, "mg_villages:plotmarker",
formspec..
"button[9.9,0.4;2,0.5;back;"..S("Back").."]"..
"button[3,3;5,0.5;create_backup;"..S("Create backup of current stage").."]"..
"button[4,4;3,0.5;show_materials;"..show_material_text.."]"..
"button[4,5;3,0.5;reset_building;"..S("Reset building").."]"..
"button[4,6;3,0.5;remove_building;"..S("Remove building").."]"
);
return;
end
local owner = plot.owner;
local btype = plot.btype;
local original_formspec = "size[8,3]"..
"button[7.0,0.0;1.0,0.5;info;"..S("Info").."]"..
"label[1.0,0.5;"..S("Plot No.").." : "..tostring( plot_nr ).."]"..
"label[2.5,0.5;"..S("Building").." : ]"..
"label[3.5,0.5;"..tostring( mg_villages.BUILDINGS[btype].scm ).."]"..
"field[20,20;0.1,0.1;pos2str;Pos;"..minetest.pos_to_string( pos ).."]";
local formspec = "";
local ifinhabit = "";
-- Get Price
local price = "default:gold_ingot 2";
if (btype ~= 'road' and mg_villages.BUILDINGS[btype]) then
local plot_descr = S("Plot No.")..' '..tostring( plot_nr )..' '..S("with")..' '..tostring( mg_villages.BUILDINGS[btype].scm)
if (mg_villages.BUILDINGS[btype].price) then
price = mg_villages.BUILDINGS[btype].price;
elseif (mg_villages.BUILDINGS[btype].typ and mg_villages.prices[ mg_villages.BUILDINGS[btype].typ ]) then
price = mg_villages.prices[ mg_villages.BUILDINGS[btype].typ ];
end
-- Get if is inhabitant house
if (mg_villages.BUILDINGS[btype].inh and mg_villages.BUILDINGS[btype].inh > 0 ) then
ifinhabit = "label[1,1.5;"..S("Owners of this plot count as village inhabitants.").."]";
end
end
-- Determine price depending on building type
local price_stack= ItemStack( price );
-- If nobody owns the plot
if (not(owner) or owner=='') then
formspec = original_formspec ..
"label[1,1;"..S("You can buy this plot for").."]"..
"label[3.8,1;"..tostring( price_stack:get_count() ).." x ]"..
"item_image[4.3,0.8;1,1;"..( price_stack:get_name() ).."]"..
ifinhabit..
"button[2,2.5;1.5,0.5;buy;"..S("Buy plot").."]"..
"button_exit[4,2.5;1.5,0.5;abort;"..S("Exit").."]";
-- On Press buy button
if (fields['buy']) then
local inv = player:get_inventory();
if not mg_villages.all_villages[village_id].ownerlist then
mg_villages.all_villages[village_id].ownerlist = {}
end
-- Check if player already has a house in the village
if mg_villages.all_villages[village_id].ownerlist[pname] then
formspec = formspec.."label[1,1.9;"..S("Sorry. You already have a plot in this village.").."]";
-- Check if the price can be paid
elseif( inv and inv:contains_item( 'main', price_stack )) then
formspec = original_formspec..
"label[1,1;"..S("Congratulations! You have bought this plot.").."]"..
"button_exit[5.75,2.5;1.5,0.5;abort;"..S("Exit").."]";
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].owner = pname;
if mg_villages.all_villages[village_id].ownerlist then
mg_villages.all_villages[village_id].ownerlist[pname] = true;
else
mg_villages.all_villages[village_id].ownerlist[pname] = true;
end
meta:set_string('infotext', S("Plot No.").." "..tostring( plot_nr ).." "..S("with").." "..tostring( mg_villages.BUILDINGS[btype].scm).." ("..S("owned by").." "..tostring( pname )..")");
-- save the data so that it survives server restart
mg_villages.save_data();
-- substract the price from the players inventory
inv:remove_item( 'main', price_stack );
else
formspec = formspec.."label[1,1.9;"..S("Sorry. You are not able to pay the price.").."]";
end
end
-- If player is the owner of the plot
elseif (owner==pname) then
-- Check if inhabitant house
if(btype ~= 'road'
and mg_villages.BUILDINGS[btype]
and mg_villages.BUILDINGS[btype].inh
and mg_villages.BUILDINGS[btype].inh > 0 ) then
ifinhabit = "label[1,1.5;"..S("You are allowed to modify the common village area.").."]";
end
formspec = original_formspec.."size[8,3]"..
"label[1,1;"..S("This is your plot. You have bought it.").."]"..
"button[0.75,2.5;3,0.5;add_remove;"..S("Add/Remove Players").."]"..
ifinhabit..
"button_exit[3.75,2.5;2.0,0.5;abandon;"..S("Abandon plot").."]"..
"button_exit[5.75,2.5;1.5,0.5;abort;"..S("Exit").."]";
-- If Player wants to abandon plot
if(fields['abandon'] ) then
formspec = original_formspec..
"label[1,1;"..S("You have abandoned this plot.").."]"..
"button_exit[5.75,2.5;1.5,0.5;abort;"..S("Exit").."]";
mg_villages.all_villages[village_id].ownerlist[pname] = nil;
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit = {}
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].owner = nil;
-- Return price to player
local inv = player:get_inventory();
inv:add_item( 'main', price_stack );
meta:set_string('infotext', S("Plot No.").." "..tostring( plot_nr ).." "..S("with").." "..tostring( mg_villages.BUILDINGS[btype].scm) );
mg_villages.save_data();
end
-- If Player wants to add/remove trusted players
if (fields['add_remove']) then
local previousTrustees = mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit
local output = "";
if previousTrustees == nil then
previousTrustees = {}
else
for _, player in ipairs(previousTrustees) do
output = output..player.."\n"
end
end
formspec = "size[8,3]"..
"field[20,20;0.1,0.1;pos2str;Pos;"..minetest.pos_to_string( pos ).."]"..
"textarea[0.3,0.2;8,2.5;ownerplayers;"..S("Trusted Players")..";"..output.."]"..
"button[3.25,2.5;1.5,0.5;savetrustees;"..S("Save").."]";
mg_villages.save_data()
end
-- Save trusted players
if (fields["savetrustees"] == "Save") then
if not mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit then
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit = {}
end
local x = 1;
for _, player in ipairs(fields.ownerplayers:split("\n")) do
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit[x] = player
x = x + 1
end
mg_villages.save_data();
end
-- If A different Player owns plot
else
formspec = original_formspec.."label[1,1;"..tostring( owner )..' '..S("owns this plot")..".]"..
"button_exit[3,2.5;1.5,0.5;abort;"..S("Exit").."]";
end
minetest.show_formspec( pname, "mg_villages:plotmarker", formspec );
end
mg_villages.form_input_handler = function( player, formname, fields)
-- mg_villages.print(mg_villages.DEBUG_LEVEL_NORMAL,minetest.serialize(fields));
if( not( mg_villages.ENABLE_PROTECTION )) then
return false;
end
if( (formname == "mg_villages:plotmarker") and fields.pos2str and not( fields.abort )) then
local pos = minetest.string_to_pos( fields.pos2str );
mg_villages.plotmarker_formspec( pos, formname, fields, player );
return true;
end
return false;
end
minetest.register_on_player_receive_fields( mg_villages.form_input_handler )

View File

@ -18,6 +18,9 @@
-- plant_type = 'farming:wheat_8' Type of plant that is placed around villages.
-- plant_frequency = 1 The higher this value is, the less plants are placed.
-- Intllib
local S = mg_villages.intllib
local village_type_data_list = {
nore = { min = 20, max = 40, space_between_buildings=1, mods={}, texture = 'default_stone_brick.png',
replacement_function = mg_villages.replacements_nore },
@ -85,7 +88,7 @@ mg_villages.add_village_type = function( type_name, v )
end
if( not( v.only_single ) and (not(v.min) or not(v.max))) then
mg_villages.print( mg_villages.DEBUG_LEVEL_NORMAL, 'Error: Village type '..tostring( type_name )..' lacks size information.');
mg_villages.print( mg_villages.DEBUG_LEVEL_NORMAL, S("Error: Village type")..' '..tostring( type_name )..' '..S("lacks size information."));
return false;
end

View File

@ -5,6 +5,9 @@
local calls;
-- Intllib
local S = mg_villages.intllib
local function is_village_block(minp)
local x, z = math.floor(minp.x/80), math.floor(minp.z/80)
local vcc = mg_villages.VILLAGE_CHECK_COUNT
@ -82,7 +85,7 @@ local function choose_building(l, pr, village_type)
if( not( mg_villages.village_type_data[ village_type ] )
or not( mg_villages.village_type_data[ village_type ][ 'building_list'] )) then
mg_villages.print( mg_villages.DEBUG_LEVEL_INFO, 'Unsupported village type: '..tostring( village_type )..' for house at '..tostring(bx)..':'..tostring(bz)..'.');
mg_villages.print( mg_villages.DEBUG_LEVEL_INFO, S("Unsupported village type").." : "..tostring( village_type )..' '..S("for house at") ' '..tostring(bx)..':'..tostring(bz)..'.');
-- ...and crash in the next few lines (because there is no real solution for this problem)
end
@ -915,8 +918,8 @@ mg_villages.houses_in_mapchunk = function( minp, mapchunk_size, villages )
table.insert( villages, candidate );
-- there may be quite a lot of single houses added; plus they are less intresting than entire villages. Thus, logfile spam is reduced
mg_villages.print( mg_villages.DEBUG_LEVEL_WARNING, 'adding SINGLE HOUSE of type '..tostring( candidate.village_type )..
' to map at '..tostring( candidate.vx )..':'..tostring( candidate.vz )..'.');
mg_villages.print( mg_villages.DEBUG_LEVEL_WARNING, S("adding SINGLE HOUSE of type")..' '..tostring( candidate.village_type )..
' '..S("to map at")..' '..tostring( candidate.vx )..':'..tostring( candidate.vz )..'.');
end
end
return villages;