Console = nil;

function DisablePunishment()
    play_field:DisablePunishment()
	Console:Log('Punishment is successfully disabled')
end

function AppExit()
    GetGameApp():DoExit(true);
end

function DisablePunishment()
    play_field:DisablePunishment()
end

function GetLevelId()
	if play_field == nil then
		Console:Log("No level loaded")
	else
	    local i, r = GetCurLevelId(play_field:GetName())
		Console:Log('Level id is '..r)
	end
end

function DebugLocalization(params)
    debug_localization = toboolean(params:get(1))
    local l = 'off'
    if debug_localization then
        l = 'on'
    end
    Console:Log('Localization debugging is '..l)
end

function LoadLevelById(params)
    StartLevelById(params:get(1))
end

--------------------------------------------------------------------------------

local ConsoleCommands = {};
ConsoleCommands['exit'] = AppExit;
ConsoleCommands['levelid'] = GetLevelId;
ConsoleCommands['restart'] = Restart;
ConsoleCommands['start'] = LoadLevelById;
ConsoleCommands['debuglocalization'] = DebugLocalization;
ConsoleCommands['disablepunishment'] = DisablePunishment;
ConsoleCommands['win'] = OnWin;
ConsoleCommands['soundvolume'] = function(params)

	GetGameApp():SetSoundVolume(tonumber(params:get(1)));

end;

function RegisterConsoleCommands()

    Console:RegisterCommand('exit');
    Console:RegisterCommand('levelid');
    Console:RegisterCommand('restart');
    Console:RegisterCommand('start');
    Console:RegisterCommand('debuglocalization');
    Console:RegisterCommand('disablepunishment');
	Console:RegisterCommand('soundvolume');
    
end


--------------------------------------------------------------------------------
function ProcessConsoleCommand(console, command)
	Console = console
    local params = ExplodeString(' ', command);

    for name, command in pairs(ConsoleCommands)
    do
        if (params:get(0) == name)
        then
            return command(params) or "";
        end
    end

    return "Command not found: " .. command;

end

--------------------------------------------------------------------------------