MBot Posted November 2, 2013 Share Posted November 2, 2013 (edited) Under certain circumstances, the script command missionCommands.removeItem() removes more items than it is supposed to do. Observe the following script which is run for a MP test mission for 2 players: helo = { [1] = { name = "helo1", active = false }, [2] = { name = "helo2", active = false } } function DummyFunction() end function PopulateRadioMenu(_id) missionCommands.removeItemForGroup(_id.groupID, nil) missionCommands.addCommandForGroup(_id.groupID, "GroupCommand1", nil, DummyFunction, _id) missionCommands.addCommandForGroup(_id.groupID, "GroupCommand2", nil, DummyFunction, _id) missionCommands.removeItem({"AllCommand"}) missionCommands.addCommand("AllCommand", nil, DummyFunction) end function CheckHeloActive() for n = 1, #helo do if Unit.getByName(helo[n].name) ~= nil and helo[n].active == false then local _id = { name = helo[n].name, groupID = Unit.getByName(helo[n].name):getGroup():getID(), num = n } PopulateRadioMenu(_id) helo[n].active = true elseif Unit.getByName(helo[n].name) == nil then helo[n].active = false end end return timer.getTime() + 1 end timer.scheduleFunction(CheckHeloActive, nil, 2) Purpose of the test is to populate the F10 Radiomenu with two group specific commands and one general command. Run the attached test mission as host to reproduce the bug: 1. Unpause the mission 2. Select helo1 and go into cockpit 3. Open F10 Radiomenu and observe the listed commands: 1. GroupCommand1 2. GroupCommand2 3. AllCommand This is as expected 4. Hit escape, select helo2 and go into cockpit 5. Open F10 Radiomenu and observe the listed commands: 1. GroupCommand1 2. AllCommand GroupCommand2 is not populated (or deleted instantly) even though it should display. If the above code is modified by removing the "AllCommands" related lines, GroupCommand1 and 2 behave as intended. As observed in further tests it seems that missionCommands.removeItem("some item") works fine the first time it is used but in subsequent uses not only removes "some item" but also the item directly above it. Edited November 2, 2013 by MBot Link to comment Share on other sites More sharing options...
Recommended Posts