Difference between revisions of "ETS Presets"
From FreeSpace Wiki
(Created page with "This script allows the player to use ETS presets, similar to those in XWA. The only catch is that the presets aren't saved over FSO restarts. AND it's still littered with debug …") |
(No difference)
|
Revision as of 09:00, 21 December 2014
This script allows the player to use ETS presets, similar to those in XWA. The only catch is that the presets aren't saved over FSO restarts. AND it's still littered with debug code from its original use for testing a new feature.
#Conditional Hooks
; ets get/set
$Application: FS2_Open
$On Game Init:
[
preset1 = { 4,4,4 }
preset2 = { 4,4,4 }
function ets_get ( target_ship )
if target_ship:isValid() then
local tmp = { 4,4,4 }
tmp[1] = target_ship.EtsEngineIndex
tmp[2] = target_ship.EtsShieldIndex
tmp[3] = target_ship.EtsWeaponIndex
return tmp
end
end
]
$State: GS_STATE_GAME_PLAY
$On State Start:
[
InputStates = {}
ui_keyToggleFunctions = {}
ui_keyToggleFunctions["5"] = function(val) InputStates.five = val end --set static indexes
ui_keyToggleFunctions["6"] = function(val) InputStates.six = val end --set preset1 to all ships
ui_keyToggleFunctions["7"] = function(val) InputStates.seven = val end --set preset1
ui_keyToggleFunctions["8"] = function(val) InputStates.eight = val end --set preset2
ui_keyToggleFunctions["9"] = function(val) InputStates.nine = val end --use preset1
ui_keyToggleFunctions["0"] = function(val) InputStates.zero = val end --use preset2
]
$On Key Pressed:
[
local key = hv.Key
local func = ui_keyToggleFunctions[key]
if func then
func(true)
end
]
$On Key Released:
[
local key = hv.Key
local func = ui_keyToggleFunctions[key]
if func then
func(false)
end
]
$On Frame:
[
if MissionTime == nil then
MissionTime = mn.getMissionTime()
OldMissionTime = MissionTime
end
MissionTime = mn.getMissionTime()
if OldMissionTime ~= MissionTime then
local pship = mn.getObjectFromSignature(hv.Player:getSignature())
--Keyboard responses
if InputStates.five then
InputStates.five = false
pship:EtsSetIndexes ( 2,2,8 )
end
if InputStates.six then
InputStates.six = false
local num_ships = #mn.Ships
for i=1,num_ships do
local ship = mn.Ships[i]
if ship:isValid() then
ship:EtsSetIndexes ( preset1[1], preset1[2], preset1[3] )
end
end
end
if InputStates.seven then
InputStates.seven = false
preset1 = ets_get (pship)
end
if InputStates.eight then
InputStates.eight = false
preset2 = ets_get (pship)
end
if InputStates.nine then
InputStates.nine = false
pship:EtsSetIndexes ( preset1[1], preset1[2], preset1[3] )
end
if InputStates.zero then
InputStates.zero = false
pship:EtsSetIndexes ( preset2[1], preset2[2], preset2[3] )
end
end
]
$On HUD Draw:
[
if hu.HUDDrawn == true then
gr.drawString(preset1[1])
gr.drawString(preset1[2])
gr.drawString(preset1[3])
gr.drawString("")
gr.drawString(preset2[1])
gr.drawString(preset2[2])
gr.drawString(preset2[3])
end
]
#End