proceeded with formspec for setting reward_id
This commit is contained in:
parent
9ec0d7719b
commit
5df77f49b9
@ -2,6 +2,7 @@
|
||||
-- low-level access, depending on internal structure of reward_inv.player_data
|
||||
|
||||
-- TODO: implement reward_inv.store_data
|
||||
-- TODO: distinguish between inv_data and player_data
|
||||
reward_inv.store_data = function()
|
||||
end
|
||||
|
||||
@ -136,3 +137,20 @@ reward_inv.grant_access = function(pname, reward_id)
|
||||
reward_inv.set_access_data(pname, reward_id, data)
|
||||
end
|
||||
|
||||
-- create reward_id data if necessary
|
||||
reward_inv.reward_id_create = function(reward_id, pos, npc_id)
|
||||
if(reward_inv.reward_id_exists(reward_id)) then
|
||||
return
|
||||
end
|
||||
-- Which player has taken how much out of this reward chest?
|
||||
reward_inv.player_data[reward_id] = {}
|
||||
-- What does the reward chest contain? Plus some statistical data etc.
|
||||
reward_inv.inv_data[reward_id] = {
|
||||
content = {},
|
||||
pos = pos,
|
||||
npc = npc_id,
|
||||
anz_found = 0,
|
||||
}
|
||||
-- write it to disc
|
||||
reward_inv.store_data()
|
||||
end
|
||||
|
||||
@ -58,6 +58,24 @@ reward_inv.input_handler = function(player, formname, fields)
|
||||
if(not(reward_id) or reward_id == "") then
|
||||
return reward_inv.show_error_msg_fs(pname, "No reward_id selected.")
|
||||
end
|
||||
|
||||
local npc_id = nil
|
||||
if(minetest.global_exists("yl_speak_up")) then
|
||||
npc_id = yl_speak_up.speak_to[pname]
|
||||
end
|
||||
-- make sure reward_id exists
|
||||
reward_inv.reward_id_create(reward_id, reward_inv.clicked_at_chest[pname], npc_id)
|
||||
|
||||
-- if it's a chest make sure reward_id is stored in its metadata
|
||||
if(reward_inv.clicked_at_chest[pname]) then
|
||||
local meta = minetest.get_meta(reward_inv.clicked_at_chest[pname])
|
||||
meta:set_string("reward_id", reward_id)
|
||||
end
|
||||
|
||||
-- the player is working on this reward and editing it (until the Store button is clicked)
|
||||
reward_inv.player_using[pname] = reward_id
|
||||
reward_inv.player_is_editing[pname] = true
|
||||
|
||||
-- TODO: actually implement
|
||||
-- if(reward_inv.clicked_at_chest[pname]) then
|
||||
minetest.chat_send_player("singleplayer", "REWARD_ID: "..tostring(reward_id))
|
||||
@ -112,7 +130,7 @@ reward_inv.get_reward_fs = function(player, reward_id)
|
||||
suggested_id = yl_speak_up.speak_to[pname]
|
||||
end
|
||||
local liste = reward_inv.get_sorted_reward_id_list()
|
||||
table.insert(formspec, "size[8,4]")
|
||||
table.insert(formspec, "size[8,4.5]")
|
||||
table.insert(formspec, "label[0,0;Not yet configured. No reward_id set. "..
|
||||
"You have the priv to set one.]")
|
||||
table.insert(formspec, "label[0,1;Select existing:]")
|
||||
@ -125,10 +143,26 @@ reward_inv.get_reward_fs = function(player, reward_id)
|
||||
table.insert(formspec, minetest.formspec_escape(suggested_id))
|
||||
table.insert(formspec, "]")
|
||||
table.insert(formspec, "button[6.8,1.8;1.2,1;create_reward_id;Create]")
|
||||
table.insert(formspec, "label[0,2.5;Note: Select a name which will help you remember "..
|
||||
table.insert(formspec, "tooltip[new_reward_id;"..
|
||||
"The reward_id you store here is needed in order to reference the reward.\n"..
|
||||
"If you are adding a treasure chest, just go with the suggested name/pos.\n"..
|
||||
"When adding a treasure for an NPC, add some description that will help\n"..
|
||||
"you remember what this reward is for.]")
|
||||
table.insert(formspec, "tooltip[create_reward_id;Click here to proceed.]")
|
||||
table.insert(formspec, "tooltip[select_reward_id;"..
|
||||
"You can select an existing reward_id.\n"..
|
||||
"Note that this is seldom necessary. It is usually only needed when you\n"..
|
||||
"moved a treasure chest a few blocks away and want to keep the data.\n"..
|
||||
"Or when you changed the dialog structure of the NPC that hands out the\n"..
|
||||
"reward.]")
|
||||
table.insert(formspec, "tooltip[set_reward_id;"..
|
||||
"Click here to store the selected reward_id. This is seldom needed.\n"..
|
||||
"Usually, creating a new one is the better choice.]")
|
||||
table.insert(formspec, "label[0,2.6;Note: Select a name which will help you remember "..
|
||||
"what this]")
|
||||
table.insert(formspec, "label[0,2.9;reward is for and/or where it will be handed out.]")
|
||||
table.insert(formspec, "button_exit[3,3.3;2,1;exit;Exit]")
|
||||
table.insert(formspec, "label[0,3.0;reward is for and/or where it will be handed out.]")
|
||||
table.insert(formspec, "label[0,3.4;In general, just click on \"Create\" to proceed.]")
|
||||
table.insert(formspec, "button_exit[3,3.9;2,1;exit;Exit]")
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user