show who owns the npc; limit length of name and description to 40 characters
This commit is contained in:
parent
26ad9b3c5a
commit
50591119c7
@ -1155,6 +1155,11 @@ local function get_fs_talkdialog(player, n_id, d_id)
|
||||
local formspec = {}
|
||||
local h
|
||||
|
||||
-- show who owns the NPC (and is thus more or less responsible for what it says)
|
||||
local owner_info = ""
|
||||
if(yl_speak_up.npc_owner[ n_id ]) then
|
||||
owner_info = "\n\n(owned by "..minetest.formspec_escape(yl_speak_up.npc_owner[ n_id ])..")"
|
||||
end
|
||||
if formspec_v >= 4 then
|
||||
formspec = {
|
||||
"formspec_version[3]",
|
||||
@ -1202,7 +1207,7 @@ local function get_fs_talkdialog(player, n_id, d_id)
|
||||
minetest.formspec_escape(dialog.n_npc),
|
||||
"]",
|
||||
"label[0.3,1.8;",
|
||||
minetest.formspec_escape(dialog.n_description),
|
||||
minetest.formspec_escape(dialog.n_description)..owner_info,
|
||||
"]",
|
||||
"image[15.5,0.5;4,4;",
|
||||
portrait,
|
||||
@ -1221,7 +1226,6 @@ local function get_fs_talkdialog(player, n_id, d_id)
|
||||
-- display the window with the text the NPC is saying
|
||||
-- TODO: make name and description likewise editable?
|
||||
-- TODO: make name of dialog and sort option editable?
|
||||
-- TODO: show who owns the npc/is responsible for its talks?
|
||||
if(edit_mode) then
|
||||
|
||||
-- TODO: sort by name?
|
||||
@ -2344,6 +2348,11 @@ minetest.register_on_player_receive_fields(
|
||||
minetest.chat_send_player(pname, "Please provide a description of your NPC!")
|
||||
return
|
||||
end
|
||||
-- sensible length limit
|
||||
if(string.len(fields.n_npc)>40 or string.len(fields.n_description)>40) then
|
||||
minetest.chat_send_player(pname, "The name and description of your NPC cannot be longer than 40 characters.")
|
||||
return
|
||||
end
|
||||
-- give the NPC its first dialog
|
||||
local f = {}
|
||||
-- create a new dialog
|
||||
|
Loading…
Reference in New Issue
Block a user