Community Forum

Tab order of vehicles

Forum Overview >> Scripting

Created26.02.2021 13:57

Bob Bobster (Bobster82) 26.02.2021 13:57

Im writing a mod for myself and need help

I want to change the "tab" order of the vehicles. Now I have something working, but its far from perfect and good practice.
I grab the g_currentMission.vehicles table and swap 2 tables (vehicles) .. Now i need to save the game (takes longer, maybe cuz of writing new xlm files) restart the savegame, then its working as I wanted.. 2 vehicles are swapped in tab order.

Can I get some help how to get this working without restarting?

part of my test function:

local tmp1 = g_currentMission.vehicles[4]
local tmp2 = g_currentMission.vehicles[18]
g_currentMission.vehicles[4] = tmp2
g_currentMission.vehicles[18] = tmp1

Bob Bobster (Bobster82) 26.02.2021 16:27
Or is it posible to override the input for tabbing?

Then when pressed tab, only my function gets the event? That would prob be the best option.

Bilbo Beutlin (BBeutlin) 26.02.2021 18:10
You don't need the auxiliary variables. To swap values in LUA you can simply write
x,y = y,x
or in an array
a[i] , a[k] = a[k] , a[i]

Anyway, the FS uses more than only the 'g_currentMission.vehicles' table. There are also some copies, eg. in the shop items.

Bob Bobster (Bobster82) 26.02.2021 21:22
Thanks for the reply,

Im not fluent in lua ;) Learned again something about swaps.
Its hard to search in the docs if you need something specific, but I found something I can work with.
spec_enterable has istabbable, I can make my workaround with that.


Note: Log in to post. Create a new account here.