Can LUA Get the Sun's Position?

Can LUA Get the Sun's Position?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Can LUA Get the Sun's Position?

Post 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...
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post 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")
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

Sunflowers :D
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Post by quantum »

Sunflowersolars!
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Dudes putting shades on when they face the sun!
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post 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!
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

rattle wrote:Dudes putting shades on when they face the sun!

and

fight

in

thier shades?


OH NO HE DIDN'T
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post 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...
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post 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...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Great, that's exactly what I needed.
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post 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.
Post Reply

Return to “Lua Scripts”