aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/basetools/textures/basetools_elementalsword.png
diff options
context:
space:
mode:
Diffstat (limited to 'games/devtest/mods/basetools/textures/basetools_elementalsword.png')
0 files changed, 0 insertions, 0 deletions
' href='#n67'>67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
--
-- exception handler test module
--
--
-- To avoid this from crashing the module will startup in inactive mode.
-- to make specific errors happen you need to cause them by following
-- chat command:
--
-- exceptiontest <location> <errortype>
--
-- location has to be one of:
--   * mapgen:          cause in next on_generate call
--   * entity_step:     spawn a entity and make it do error in on_step
--   * globalstep:      do error in next globalstep
--   * immediate:       cause right in chat handler
--
-- errortypes defined are:
--   * segv:            make sigsegv happen
--   * zerodivision:    cause a division by zero to happen
--   * exception:       throw an exception

if core.cause_error == nil or
	type(core.cause_error) ~= "function" then
	return
end
	

core.log("action", "WARNING: loading exception handler test module!")

local exceptiondata = {
	tocause = "none",
	mapgen = false,
	entity_step = false,
	globalstep = false,
}

local exception_entity =
{
	on_step = function(self, dtime)
		if exceptiondata.entity_step then
			core.cause_error(exceptiondata.tocause)
		end
	end,
}
local exception_entity_name = "errorhandler_test:error_entity"

local function exception_chat_handler(playername, param)
	local parameters = param:split(" ")
	
	if #parameters ~= 2 then
		core.chat_send_player(playername, "Invalid argument count for exceptiontest")
	end
	
	core.log("error", "Causing error at:" .. parameters[1])
	
	if parameters[1] == "mapgen" then
		exceptiondata.tocause = parameters[2]
		exceptiondata.mapgen = true
	elseif parameters[1] == "entity_step" then
		--spawn entity at player location