Whicker
Posts: 664
Joined: 6/20/2018 Status: offline
|
hmm. How many sam units? Your example code is for a mission, I don't think it would do much for the unit visibility would it? but here are some notes on what I think the code is doing: -- Set mission to start n minutes from current game time "now" function SetMissionStartTime(sideName,missionName,minutesFromNow) -- this is function! it needs to be called and have the 3 parameters passed in to it local currentTime = ScenEdit_CurrentTime() -- getting the current game time, which is in seconds from 1970 I think local currentMission = ScenEdit_GetMission(sideName,missionName) -- get mission table/data from the passed in sidename and mission name (removed an extra = sign that doesn't make sense) currentTime = currentTime + 5 * 60 * 60 + minutesFromNow * 60 --change that time by adding 5 hours for some reason? time zone adjuistment maybe? then adds the time from now that is requested, the *60 is to convert it to seconds - and the *60 *60 is to convert the 5 to seconds so it must be 5 hours? currentMission.isactive = false --set mission to not active currentMission.starttime = os.date("%m/%d/%%I%M%p", currentTime) --set star time of mission. os.date is to set the formatting of the time that was calculated into what the game is expecting - somewhere there is list of what m,d,I,M and p means. Something like month day, minutes and seconds? no idea without referring to the definitions. end --closes function That function would be called somewhere like: SetMissionStartTime('Blue','bombers mission',120) Time is fairly confusing - the 5 in this code is odd, I don't think it is usually needed. All that said what it looks like you would be trying to do is create a new event, with a trigger of 2 minutes from now, and lua to reverse the unit visibility. Events and time are different still, there is quite a bit of info in here about that where I was asking about how to do this. If you want another good example - the downed pilot code originally by Angster has all kinds of stuff in it, like creating new events and triggers at x minutes from now. I have played with it quite a bit and wrote about it here (link below) as well as posted the full code of it. I highly recommend it as a learning experience. I understood about half of what he did, and built on that. Some of how he did it is still a mystery to me: https://commandops.github.io/posts/survivors-script/ It may be a better idea to create a list of sams, and check them every 5 minutes, and if they are set to auto detect change it back. That would probably be a lot simpler, but would not do exactly what you want - it might run 20 seconds after your other code changed it. Maybe also you could do something with the same satellite leaving the area? not too sure about that.
< Message edited by Whicker -- 11/26/2018 8:44:00 PM >
|