Page 1 of 1

Can LUA Get the Sun's Position?

Posted: 08 Jun 2007, 00:44
by Argh
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...

Posted: 08 Jun 2007, 09:29
by MelTraX
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")

Posted: 08 Jun 2007, 16:05
by Snipawolf
Sunflowers :D

Posted: 08 Jun 2007, 17:53
by quantum
Sunflowersolars!

Posted: 08 Jun 2007, 23:12
by rattle
Dudes putting shades on when they face the sun!

Posted: 09 Jun 2007, 05:15
by Argh
Ok, so... let's say that I parse that... um... how do I parse that teeny, tiny sub-section, and post it to a global variable?

Sorry in advance, yes I'm ignorant. Fortunately, ignorance is curable.

And yes, I am going to use it for something like the above crazy ideas!

Posted: 09 Jun 2007, 06:15
by smoth
rattle wrote:Dudes putting shades on when they face the sun!

and

fight

in

thier shades?


OH NO HE DIDN'T

Posted: 09 Jun 2007, 06:41
by Argh
No, but that'd be awesome.

Maybe after I am done with this, though. I really did get all of the necessary ingredients working, in tests. And now I'm learning the human-animation stuff that's necessary to script it :lol:

Ok, enough side-jaunts...

Posted: 09 Jun 2007, 11:24
by MelTraX
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:

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)
Hope that helps...

Posted: 11 Jun 2007, 00:50
by Argh
Great, that's exactly what I needed.

Posted: 11 Jun 2007, 02:20
by Neddie
smoth wrote:
rattle wrote:Dudes putting shades on when they face the sun!

and

fight

in

thier shades?


OH NO HE DIDN'T
The comedy police is coming.