Mav87th Posted February 22 Posted February 22 Hi - its likely a no, but is there scriptwise a way to retreive the magnetic variance at a units location like fx. (getMagneticDeclination())? Kola map has a pretty large variance in the Magnetic Declination over very short distances, so a constant is not "really" useful. I could create a table, but that is a very "local" solution and does not lend much freedom in moving the units around afterwards.
Chump Posted February 23 Posted February 23 (edited) @Mav87th Have you tried something like: -- includes local magvar = require("magvar") local terrain = require("terrain") -- taken from /Scripts/utils_common.lua local function toDegrees(radians) return radians * 180 / math.pi end -- get unit position local unit = Unit.getByName("MyUnit") local p = unit:getPosition().p -- convert x,y to lat,lon local lat, lon = terrain.convertMetersToLatLon(p.x, p.z) -- set month/year from mission magvar.init(env.mission.date.Month, env.mission.date.Year) -- get magvar local mv = toDegrees(magvar.get_mag_decl(lat, lon)) -- pretty print local txt = string.format("%+0.1f°", mv) trigger.action.outText(txt, 10) Edited February 24 by Chump Fixed code
buur Posted February 23 Posted February 23 @Chump tried it with desanitazion but get the error that the command require is missing.
Chump Posted February 24 Posted February 24 @buur Yes, you will need to comment out the following line in /scripts/MissionScripting.lua in order to use require: _G['require'] = nil
buur Posted February 24 Posted February 24 @Chump no luck. Now I have the problem that utils_common not found.
Chump Posted February 24 Posted February 24 @buur I fixed the code above. I wrote it from memory without testing it late at night. </excuses> It can be executed in a mission now. 1
buur Posted February 25 Posted February 25 vor 12 Stunden schrieb Chump: @buur I fixed the code above. I wrote it from memory without testing it late at night. </excuses> It can be executed in a mission now. ok, now it works. Thanks for your efforts. Great to know that it is possible to get the magnetic variation.
Recommended Posts