Can LUA Get the Sun's Position?
Moderator: Moderators
Can LUA Get the Sun's Position?
That's all... any way to read that value from the .SMD and pass it to a COB? I don't care if it's the raw positional stuff or whatever...
That's no problem.. You can read every file.. I don't know if there already is a parser for that kind of file but if not you can just get the value with regular expressions or something similar.. To read the contents of the smd:
Code: Select all
local content = VFS.LoadFile("maps/" .. string.sub(Game.mapName, 0, -2) .. "d")
I don't know anything about COB or making maps but if you want to extract the SunDir values from the smd, you simply do:
Hope that helps...
Code: Select all
local content = VFS.LoadFile("maps/" .. string.sub(Game.mapName, 0, -2) .. "d")
local _, _, numOne, numTwo, numThree = content:find("SunDir=([0-9]+) ([0-9]+) ([0-9]+);")
Spring.Echo(numOne .. " - " .. numTwo .. " - " .. numThree)