Reordering slots

Workshop for all Mission Engineer Comrades. Home of the FA Mission Making Template.
Post Reply
User avatar
Posts: 136
Joined: Mon Jan 21, 2013 6:04 am

Reordering slots

Post by Crocuta » Thu Aug 15, 2013 7:18 pm

I made my first Arma mission using the latest F3, and then published it on Steam Workshop (is that ok?) ... =167978911

Because it's a small 12 player Indfor coop, I deleted everything but ASL, A1, A2, ENG1. In the slotting screen it's all muddled up, and Arma 3 likes to also give groups their own names. Ordering on slotting goes as: ASL (Alpha 1-1), A2 (Alpha 1-2), ENG1 (Alpha 1-3), A1 (Alpha 2-1).

Does anyone know how to change the order of the slots, and if possible to also get rid of (or alter) Arma 3's own naming system?

User avatar
Posts: 1208
Joined: Wed May 25, 2011 4:59 pm

Re: Reordering slots

Post by wolfenswan » Thu Aug 15, 2013 8:57 pm

Would be stupid if it wasn't okay :D Though I'd suggest giving it a more detailed description and maybe adding "made with the F3 Mission Making Framework" at the end. Just a suggestion though.

You have to "cut" groups with CTRL-x and paste it again with CTRL-v in the order you want them to appear. Arma's stupid like that. You could also edit the unit IDs in the mission.sqm but I wouldn't recommend that.

User avatar
Ferrard Carson
Posts: 565
Joined: Sun Aug 12, 2012 6:08 am

Re: Reordering slots

Post by Ferrard Carson » Thu Aug 15, 2013 11:59 pm

wolfenswan wrote:You could also edit the unit IDs in the mission.sqm but I wouldn't recommend that.
This is what I do. List all the GroupIDs and the units they correspond to, then go in and individual re-jigger them according to where they should be on the list. It takes a damn long time (adding units to Rook Valley SE took an hour to re-jigger the unit orderings) but it works really well if you do it correctly. If you mess up and double-assign a number, you're screwed though.

~ Ferrard
"Take a boat in the air you don't love, she'll shake you off just as sure as the turnin' of the worlds. Love keeps her in the air when she oughta fall down, tells you she's hurtin' before she keels... makes her home."

User avatar
Posts: 136
Joined: Mon Jan 21, 2013 6:04 am

Re: Reordering slots

Post by Crocuta » Fri Aug 16, 2013 1:14 pm

Thank you, I have it set up properly now. For some reason I assumed that it was a problem with F3 rather than one of Arma's many idiosyncrasies. I also see how I could have done it through the mission.sqm.

User avatar
Posts: 136
Joined: Mon Jan 21, 2013 6:04 am

Re: Reordering slots

Post by Crocuta » Sat Aug 17, 2013 1:02 am

I don't know whether anything like this already exists, but I threw together a Lua 5.1 script for reordering groups in the mission.sqm

Code: Select all

local function processMission(mode)
	-- group item iterator
	local function groups(groupStr)
		local index = 1
		return function ()
			local s, e = string.find(groupStr, "class Item%d+.-%b{};", index)
			if s then
				index = e + 1
				return string.sub(groupStr, s, e)
			else return nil end

	-- load sqm mission into string
	local fl ="mission.sqm")
	local mission = fl:read("*a")

	-- make backup of mission.sqm
	local fl ="mission_backup.sqm", "w")

	-- search for group definitions segment
	local gr_start, gr_end = string.find(mission, "class Groups.-%b{};")

	if mode == "output" then
		local fl ="reorder_list.txt", "w")
		-- use group iterator
		for gr in groups(string.sub(mission, gr_start, gr_end)) do
			-- if first element in group has description then write it to file
			local writeStr = gr:match("description=(.-);")
			if writeStr then fl:write(writeStr .. "\n") end
		print("\n ..DONE..\n")
	elseif mode == "order" then
		local orderedList = {}
		-- make numbered table of ordered groups
		for line in io.lines("reorder_list.txt") do
			if string.match(line, "(\".-\")") then table.insert(orderedList, line) end

		local groupList = {}

		-- if group leader has description: add group to table with
		-- description as the key
		-- else add group with numbered key
		for gr in groups(string.sub(mission, gr_start, gr_end)) do
			local v1, v2 = string.find(gr, "description=.-;")
			if v1 then
				local desc = gr:match("description=(.-);")
				groupList[desc] = gr
			else table.insert(groupList, gr) end

		-- open sqm and write everything before group item definitions
		local missionFile ="mission.sqm", "w")
		local v1, v2 = string.find(mission, "items=%d+;", gr_start)
		missionFile:write(string.sub(mission, 1, v2+1))

		-- increment item number for group
		local function incItem(str, num)
			local v1, v2 = string.find(str, "class Item%d+")
			return "\n\t\tclass Item" .. string.gsub(string.sub(str, v1, v2), "class Item(%d+)", tostring(num)) .. string.sub(str, v2 + 1)

		-- starting from 0, write the ordered group items to sqm
		local index = 0
		for i, v in ipairs(orderedList) do
			missionFile:write(incItem(groupList[v], index))
			index = index + 1

		-- write all other undescribed groups from last index
		for i, v in ipairs(groupList) do
			missionFile:write(incItem(v, index))
			index = index + 1

		-- write everything else after group definitions
		missionFile:write("\n\t}" .. string.sub(mission, gr_end))
		print("\n ..DONE..\n")

io.write("\tmission.sqm reorder\n\t-------------------\n")
io.write("After choosing to output groups (Option 1), rearrange the element leaders in reorder_list.txt so that each has its own line. Save the file and then choose reorder groups (Option 2).")
io.write("\n\n 1. Ouput groups\n 2. Reorder groups\n 3. Quit\n\n")

while true do
	io.write(" >")
	local ch =
	if ch == "1" then
	elseif ch == "2" then
		-- check if group_order.txt exists
		local fl ="reorder_list.txt","r")
		if fl ~= nil then
		else print("No reorder_list.txt file. Choose option 1 first!") end
	elseif ch == "3" or ch == "q" then break end
If you want to test it, install a Lua 5.1 interpreter (will probably also work with 5.2). Save the code above as something like "reorder.lua" and put it in the folder of the mission you want to use it on. FOR THE LOVE OF GOD backup your mission.sqm file. Execute the script, and choosing the first option will spit out a text file containing the description entry of the most senior unit in each group. If there's no description it won't be listed. Reorder the names by hand so that each has its own line in the file. Then choose to reorder in the script and it should be done. The units from the text file are bumped up to Item0, Item1, etc.

I have no experience with sqm files so don't know whether I've just made a bunch of garbage that seems to work at the moment.

Post Reply