Merge branch 'master' of https://github.com/thomasrudin-mt/missions
This commit is contained in:
commit
94af61dd71
11
executor.lua
11
executor.lua
@ -34,6 +34,14 @@ missions.start = function(pos, player)
|
||||
missions.set_current_mission(player, mission)
|
||||
end
|
||||
|
||||
local after_mission_hook = function(player)
|
||||
-- restore interact, no matter what
|
||||
local playername = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
privs.interact = true
|
||||
minetest.set_player_privs(playername, privs)
|
||||
end
|
||||
|
||||
-- update the mission
|
||||
local update_mission = function(mission, player)
|
||||
|
||||
@ -53,6 +61,8 @@ local update_mission = function(mission, player)
|
||||
|
||||
-- increment counter
|
||||
block_meta:set_int("successcount", block_meta:get_int("successcount") + 1)
|
||||
|
||||
after_mission_hook(player)
|
||||
return
|
||||
end
|
||||
|
||||
@ -81,6 +91,7 @@ local update_mission = function(mission, player)
|
||||
|
||||
-- increment counter
|
||||
block_meta:set_int("failcount", block_meta:get_int("failcount") + 1)
|
||||
after_mission_hook(player)
|
||||
end
|
||||
|
||||
if abort then
|
||||
|
@ -12,11 +12,12 @@ missions.form.missionblock_config = function(pos, node, player)
|
||||
|
||||
local hidden_str = "Hidden "
|
||||
if hidden == 0 then
|
||||
hidden_str = hidden_str .. "<True>"
|
||||
else
|
||||
hidden_str = hidden_str .. "<False>"
|
||||
else
|
||||
hidden_str = hidden_str .. "<True>"
|
||||
end
|
||||
|
||||
|
||||
local formspec = "size[8,8;]" ..
|
||||
--left
|
||||
"label[0,0;Mission editor]" ..
|
||||
|
@ -86,7 +86,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
|
||||
|
||||
local stepdata = spec.create()
|
||||
local stepdata = nil
|
||||
if spec.create then
|
||||
stepdata = spec.create()
|
||||
end
|
||||
|
||||
local step = {
|
||||
type = spec.type,
|
||||
name = spec.name,
|
||||
|
1
init.lua
1
init.lua
@ -63,6 +63,7 @@ dofile(MP.."/steps/givereward.lua")
|
||||
dofile(MP.."/steps/message.lua")
|
||||
dofile(MP.."/steps/teleport.lua")
|
||||
dofile(MP.."/steps/grant.lua")
|
||||
dofile(MP.."/steps/revokeinteract.lua")
|
||||
dofile(MP.."/steps/givebook.lua")
|
||||
dofile(MP.."/steps/checkpriv.lua")
|
||||
dofile(MP.."/steps/limitedtries.lua")
|
||||
|
@ -27,4 +27,4 @@ missions.migrate_mission_block = function(pos, meta)
|
||||
meta:set_int("failcount", 0)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -27,6 +27,11 @@ missions.show_step_editor = function(pos, node, player, stepnumber, step, stepda
|
||||
|
||||
for i,spec in ipairs(missions.steps) do
|
||||
if spec.type == step.type then
|
||||
if not spec.edit_formspec then
|
||||
missions.form.missionblock_stepeditor(pos, node, player)
|
||||
return
|
||||
end
|
||||
|
||||
local formspec = spec.edit_formspec({
|
||||
pos=pos,
|
||||
node=node,
|
||||
|
20
steps/revokeinteract.lua
Normal file
20
steps/revokeinteract.lua
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
missions.register_step({
|
||||
|
||||
type = "revokeinteract",
|
||||
name = "Temporary revoke interact",
|
||||
|
||||
on_step_enter = function(ctx)
|
||||
local player = ctx.player
|
||||
local name = player:get_player_name()
|
||||
|
||||
local privs = minetest.get_player_privs(name)
|
||||
privs.interact = nil
|
||||
minetest.set_player_privs(name, privs)
|
||||
|
||||
ctx.on_success()
|
||||
end
|
||||
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user