mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-22 15:23:47 +01:00
Made some grammatical corrections
This commit is contained in:
parent
6f681a2f4c
commit
7d77eb3a41
@ -49,17 +49,17 @@ Additionally, `playerfactions` can optionally depend on the following mods:
|
|||||||
|
|
||||||
I strongly recommend reading through the `init.lua` file; the functions at the top give you a pretty good idea of how to use it, but just in case you're short on time I'll list the most important functions below.
|
I strongly recommend reading through the `init.lua` file; the functions at the top give you a pretty good idea of how to use it, but just in case you're short on time I'll list the most important functions below.
|
||||||
|
|
||||||
- `factions.version` is a variable to check the version of the playerfactions mod to assert compatibility:
|
- `factions.version` is a variable made to check the version of the playerfactions mod to assert compatibility:
|
||||||
* factions.version == nil for firsts version of playerfactions mod
|
* factions.version == nil for firsts version of playerfactions mod
|
||||||
* factions.version == 2 is the first time this variable is added, with adding multi-faction mode
|
* factions.version == 2 is the first time this variable is added, with adding multi-faction mode
|
||||||
- `player_is_in_faction(fname, player_name)`: true if the player is in the faction, nil in other cases
|
- `player_is_in_faction(fname, player_name)`: `true` if the player is in the faction, `nil` in other cases (facion or player doesn't exists or player is not a member of the faction)
|
||||||
- `get_facts()`: Get the table with all data. The structure is :
|
- `get_facts()`: Get the table with all data. The structure is :
|
||||||
```{["name_of_faction1"]={
|
```{["name_of_faction1"]={
|
||||||
["owner"]=name_of_the_owner,
|
["owner"]=name_of_the_owner,
|
||||||
["members"]={["name_of_a_member1"]=true, ["name_of_a_member2"]=true}
|
["members"]={["name_of_a_member1"]=true, ["name_of_a_member2"]=true}
|
||||||
}}
|
}}
|
||||||
```
|
```
|
||||||
- `get_player_faction(player)`: Get a string with the faction a player belongs to, `nil` if they haven't joined a faction. In multi-faction mode, it will return the oldest faction which player is into. (It checks the facts variable from the top)
|
- `get_player_faction(player)`: Get a string with the faction a player belongs to, `nil` if they haven't joined a faction. In multi-faction mode, it will return the oldest created faction which player is into. (it's not necessarily the one they joined first. It checks the facts variable from the top)
|
||||||
- `get_player_factions(player)`: Get a table with the faction(s) a player belongs to, `nil` if they haven't joined a faction : {name_of_faction1, name_of_faction2}
|
- `get_player_factions(player)`: Get a table with the faction(s) a player belongs to, `nil` if they haven't joined a faction : {name_of_faction1, name_of_faction2}
|
||||||
- `get_owner(faction)`: Get the owner of a faction
|
- `get_owner(faction)`: Get the owner of a faction
|
||||||
- `chown(fname, owner)`: Change the owner of a faction
|
- `chown(fname, owner)`: Change the owner of a faction
|
||||||
@ -68,7 +68,7 @@ I strongly recommend reading through the `init.lua` file; the functions at the t
|
|||||||
- `get_password(faction)`: Gets a faction's password
|
- `get_password(faction)`: Gets a faction's password
|
||||||
- `set_password(faction, password)`: Sets a faction's password
|
- `set_password(faction, password)`: Sets a faction's password
|
||||||
- `join_faction(faction, player)`: Sets the given player as belonging to this faction
|
- `join_faction(faction, player)`: Sets the given player as belonging to this faction
|
||||||
- `leave_faction(player)`: Clears a player's faction
|
- `leave_faction(faction, player)`: Remove the given player from the faction
|
||||||
|
|
||||||
Note that all of these functions have sanity checks : if faction or player does not exists, it return false. If operation succeed, it return true or the needed value.
|
Note that all of these functions have sanity checks : if faction or player does not exists, it return false. If operation succeed, it return true or the needed value.
|
||||||
|
|
||||||
|
21
init.lua
21
init.lua
@ -5,7 +5,7 @@ local S, NS = dofile(MP.."/intllib.lua")
|
|||||||
|
|
||||||
-- Data
|
-- Data
|
||||||
factions = {}
|
factions = {}
|
||||||
-- This variable "version" can be used by other mods to check the compatibility of the mods
|
-- This variable "version" can be used by other mods to check the compatibility of this mod
|
||||||
factions.version = 2
|
factions.version = 2
|
||||||
|
|
||||||
local facts = {}
|
local facts = {}
|
||||||
@ -190,9 +190,9 @@ local function handle_command(name, param)
|
|||||||
local own_factions = factions.get_owned_factions(name)
|
local own_factions = factions.get_owned_factions(name)
|
||||||
local number_factions = #own_factions
|
local number_factions = #own_factions
|
||||||
if number_factions == 0 then
|
if number_factions == 0 then
|
||||||
password = "No importance, player will not be abble because player is not the owner of no faction"
|
password = "No importance, player won't be able because player is the owner of no faction"
|
||||||
elseif #params == 1 then
|
elseif #params == 1 then
|
||||||
faction_name = "No importance, player will not be abble because no password is given"
|
faction_name = "No importance, player won't be able because no password is given"
|
||||||
elseif #params == 2 and number_factions == 1 then
|
elseif #params == 2 and number_factions == 1 then
|
||||||
password = params[2]
|
password = params[2]
|
||||||
faction_name = own_factions[1]
|
faction_name = own_factions[1]
|
||||||
@ -236,9 +236,6 @@ local function handle_command(name, param)
|
|||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
faction_name = factions.get_player_faction(name)
|
faction_name = factions.get_player_faction(name)
|
||||||
minetest.chat_send_player(name, S("No faction were given, returning information about your oldest faction (e.g. the oldest created faction you are in)"))
|
minetest.chat_send_player(name, S("No faction were given, returning information about your oldest faction (e.g. the oldest created faction you are in)"))
|
||||||
end
|
|
||||||
if faction_name == nil then
|
|
||||||
minetest.chat_send_player(name, S("Missing faction name"))
|
|
||||||
elseif facts[faction_name] == nil then
|
elseif facts[faction_name] == nil then
|
||||||
minetest.chat_send_player(name, S("This faction is not registered"))
|
minetest.chat_send_player(name, S("This faction is not registered"))
|
||||||
else
|
else
|
||||||
@ -250,7 +247,7 @@ local function handle_command(name, param)
|
|||||||
fmembers = fmembers..", "..play
|
fmembers = fmembers..", "..play
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, S("Name: @1\nOwner: @2\nMembers: #@3", faction_name, factions.get_owner(faction_name), fmembers))
|
minetest.chat_send_player(name, S("Name: @1\nOwner: @2\nMembers: @3", faction_name, factions.get_owner(faction_name), fmembers))
|
||||||
if factions.get_owner(faction_name) == name or minetest.get_player_privs(name).playerfactions_admin then
|
if factions.get_owner(faction_name) == name or minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Password: @1", factions.get_password(faction_name)))
|
minetest.chat_send_player(name, S("Password: @1", factions.get_password(faction_name)))
|
||||||
end
|
end
|
||||||
@ -328,7 +325,7 @@ local function handle_command(name, param)
|
|||||||
elseif target == nil then
|
elseif target == nil then
|
||||||
minetest.chat_send_player(name, S("Missing player name"))
|
minetest.chat_send_player(name, S("Missing player name"))
|
||||||
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied"))
|
minetest.chat_send_player(name, S("Permission denied: you are not the owner of this faction"))
|
||||||
elseif not facts[faction_name].members[target] then
|
elseif not facts[faction_name].members[target] then
|
||||||
minetest.chat_send_player(name, S("This player is not in the faction"))
|
minetest.chat_send_player(name, S("This player is not in the faction"))
|
||||||
elseif target == name then
|
elseif target == name then
|
||||||
@ -363,7 +360,7 @@ local function handle_command(name, param)
|
|||||||
faction_name = params[2]
|
faction_name = params[2]
|
||||||
password = params[3]
|
password = params[3]
|
||||||
elseif facts[params[2]] ~= nil then
|
elseif facts[params[2]] ~= nil then
|
||||||
faction_name = params[2]
|
faction_name = "No importance, there is no password"
|
||||||
end
|
end
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
if number_factions == 0 then
|
if number_factions == 0 then
|
||||||
@ -374,7 +371,7 @@ local function handle_command(name, param)
|
|||||||
elseif password == nil then
|
elseif password == nil then
|
||||||
minetest.chat_send_player(name, S("Missing password"))
|
minetest.chat_send_player(name, S("Missing password"))
|
||||||
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied"))
|
minetest.chat_send_player(name, S("Permission denied: you are not the owner of this faction"))
|
||||||
else
|
else
|
||||||
if factions.set_password(faction_name, password) then
|
if factions.set_password(faction_name, password) then
|
||||||
minetest.chat_send_player(name, S("Password has been updated"))
|
minetest.chat_send_player(name, S("Password has been updated"))
|
||||||
@ -392,7 +389,7 @@ local function handle_command(name, param)
|
|||||||
local password = nil
|
local password = nil
|
||||||
if #params < 3 then
|
if #params < 3 then
|
||||||
faction_name = "No importance, there is no target or no password"
|
faction_name = "No importance, there is no target or no password"
|
||||||
if minetest.player_exists(params[2]) then
|
if params[2] ~= nil and minetest.player_exists(params[2]) then
|
||||||
target = "No importance, there is no password"
|
target = "No importance, there is no password"
|
||||||
end
|
end
|
||||||
elseif number_factions == 0 then
|
elseif number_factions == 0 then
|
||||||
@ -446,7 +443,7 @@ local function handle_command(name, param)
|
|||||||
minetest.chat_send_player(name, S("The player is already in the faction \"@1\"",factions.get_player_faction(target)))
|
minetest.chat_send_player(name, S("The player is already in the faction \"@1\"",factions.get_player_faction(target)))
|
||||||
else
|
else
|
||||||
if factions.join_faction(faction_name, target) then
|
if factions.join_faction(faction_name, target) then
|
||||||
minetest.chat_send_player(name, "The player is now a member of the guild")
|
minetest.chat_send_player(name, "The player is now a member of the faction")
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Error on adding @1 into @2, please verify parameters and try again", target, faction_name))
|
minetest.chat_send_player(name, S("Error on adding @1 into @2, please verify parameters and try again", target, faction_name))
|
||||||
|
Loading…
Reference in New Issue
Block a user