local script = globalObject;

local player = nil;

local commandMap = {};

local mgun, mgun_b, rlauncher, mines = nil, nil, nil, nil;


local function ExecuteCommands()
	while(SetNextCommand(script))
	do
		local command = GetCurrentCommand(script);
		if (commandMap[command])
		then
--			CheckString(command);
			commandMap[command]();
			
		end
	end
end


local function AddObject()
	player = StringToPointer(GetCurrentParams(script));

--~ 	mgun = FindObject(player, "mgun");
--~ 	SetObjectVisible(mgun, false);
--~ 	mgun_b = FindObject(player, "mgun_b");
--~ 	SetObjectVisible(mgun_b, false);
--~ 	rlauncher = FindObject(player, "rlauncher");
--~ 	SetObjectVisible(rlauncher, false);
--~ 	mines = FindObject(player, "mines");
--~ 	SetObjectVisible(mines, false);
end

local function DeleteObject()
	Release(player);
	player = nil;
	StopScript(script);
end

local function ReleaseAll()
	DeactivateInterface(player);
	player = nil;
end

local function SetActive()
	local x, y, z = GetPosition(player);
	SetDirectParameters2(x, y, z);
end

commandMap["add_object"] = AddObject;
commandMap["delete_object"] = DeleteObject;
commandMap["release_all"] = ReleaseAll;
commandMap["set_active"] = SetActive;

while(true)
do
	ExecuteCommands();
	
	Update();
end
