Hard Light Productions Forums
Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: DefCynodont119 on June 07, 2016, 10:02:29 pm
-
EDIT: see 6th post for complete script.
I know that this is a noob question, but I need some help making a SEXP-triggered version of the Escort-reticle script: http://www.hard-light.net/wiki/index.php/Script_-_Escort_Reticle The goal is to have it apply only to one mission./turn it on and off on command.
I checked the Wiki and the forums, (including this thread: http://www.hard-light.net/forums/index.php?topic=67711.0 ) as well as looked at some other examples of scripts, however none of that has been of much use beyond a certain point.
I have a rough idea of what i need to do, but i could very easily be wrong. :blah:
EX. Should I replace $On Game Init:
with $State: GS_STATE_GAME_PLAY
$On State Start:
and if so, what I do with $On HUD Draw:
[
if missiontime == nil then
missiontime = mn.getMissionTime()
oldmissiontime = missiontime
end
?
I'm new to this in case you haven't noticed :p
If someone could be so kind as to explain to me how to modify the script accordingly, or at least make the script and post it below, It would help me a lot.
Thanks in advance -DefCynodont119
-
What I would do is add in a EscortRetEnabled variable into the conditional with if missiontime ~= nil then
so its like
if (missiontime ~= nil) and EscortRetEnabled then
Then in the mission you want it to only appear, do a script-eval where you do
EscortRetEnabled = true
And then it should turn on. But keep in mind that variable would stay on until the game closes, so you would need to turn it off manually with a script-eval of
EscortRetEnabled = nil
Hope that helps!
-
That Helps a lot Axem! didn't expect a response that fast but two things: the correct way to implement this in the table would be:
#Conditional Hooks
$Application: FS2_Open
$On Game Init:
[
drawReticle = function(ship)
if ship.Team.Name == "Hostile" then gr.setColor(255,50,50,255)
elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
elseif ship.Team.Name == "Unknown" then gr.setColor(255,255,0,255)
end
local x
local y
local x1
local y1
x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
if x ~= nil and y1 ~= nil then gr.drawString(ship.Name, x, y1 + 4) end
end
]
$On HUD Draw:
[
if (missiontime ~= nil) and EscortRetEnabled then
missiontime = mn.getMissionTime()
oldmissiontime = missiontime
end
if (missiontime ~= nil) and EscortRetEnabled then
if hu.HUDDrawn then
missiontime = mn.getMissionTime()
if oldmissiontime ~= missiontime then
if mn.EscortShips ~= nil then
NumberEscorted = #mn.EscortShips
for i= 1,NumberEscorted do
escortedship = mn.EscortShips[i]
if escortedship.Position:getScreenCoords() ~= false then
drawReticle(escortedship)
end
end
end
end
end
oldmissiontime = missiontime
end
]
#End
Right? or am I missing something obvious. because just doing that (and adding script-eval SEXPs) doesn't seem to work.
EDIT: so i didn't want to replace (missiontime == nil) with the other one, just (missiontime ~= nil). got it. it works now.
Also, what should I do if the player decides to quit mid-mission? well. . . I could add an event with EscortRetEnabled = nil to the start of every other mission in the game, buuut. . . :warp:
Once again, thank you!
-
Also, what should I do if the player decides to quit mid-mission? well. . . I could add an event with EscortRetEnabled = nil to the start of every other mission in the game, buuut. . . :warp:
What about setting EscortRetEnabled to nil in the "$On Mission End:" hook?
-
Also, what should I do if the player decides to quit mid-mission? well. . . I could add an event with EscortRetEnabled = nil to the start of every other mission in the game, buuut. . . :warp:
What about setting EscortRetEnabled to nil in the "$On Mission End:" hook?
It would be better to initialize the variables in the $On Gameplay Start: hook. Then all variables always have the right value on mission start so if the player quits the mission the next mission start will reset the variables to the initial values again.
-
@m!m That's what I was thinking of doing, but I never worked with FSO scripts or LUA and despite my best efforts of reading the wiki, I'm still not sure how to add most of the above mentioned stuff without braking the script.
Still, all of this helps so far. thank you all of you.
-
I got it! ;)
#Conditional Hooks
$Application: FS2_Open
$On Game Init:
[
drawReticle = function(ship)
if ship.Team.Name == "Hostile" then gr.setColor(255,50,50,255)
elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
elseif ship.Team.Name == "Unknown" then gr.setColor(255,255,0,255)
end
local x
local y
local x1
local y1
x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
if x ~= nil and y1 ~= nil then gr.drawString(ship.Name, x, y1 + 4) end
end
]
$On Gameplay Start:
[
if EscortRetEnabled then
EscortRetEnabled = nil
end
]
$On HUD Draw:
[
if missiontime == nil then
missiontime = mn.getMissionTime()
oldmissiontime = missiontime
end
if (missiontime ~= nil) and EscortRetEnabled then
if hu.HUDDrawn then
missiontime = mn.getMissionTime()
if oldmissiontime ~= missiontime then
if mn.EscortShips ~= nil then
NumberEscorted = #mn.EscortShips
for i= 1,NumberEscorted do
escortedship = mn.EscortShips[i]
if escortedship.Position:getScreenCoords() ~= false then
drawReticle(escortedship)
end
end
end
end
end
oldmissiontime = missiontime
end
]
#End
what I needed to do was add $On Gameplay Start:
[
if EscortRetEnabled then
EscortRetEnabled = nil
end
]
and fix the misplaced ~ I had. It works now! Thanks Everyone!
-DefCynodont119