It also prints out the results in a message box begin SinScript All the script does is take the sin of what's in SinIN and set SinOUT to the result, then take cos of what's in CosIN and set CosOUT to the result of that. Here's a very simple example script which assumes the existence of 4 global floats: SinIN, SinOUT, CosIN, CosOUT. Modulo gives you the remainder of division operation. There are similar expansions for any trig/math function. You'd likely have to use more values than in the SIN case to get a similar accuracy (though I haven't checked).
LN can be expressed in a series similar to the SIN example, though it is slightly more complex: x1 = ( Value - 1 ) / ( Value + 1 )
The math mod can either be included with your mod or you can use the scripts as a basis for your own. This contains the following functions: SquareRoot Sine Cosine Tangent NaturalLog Log intPower intRoot Modulus Antiln Antilog AbsoluteValue Power Ghan Buri Ghan's Scripting for Dummies mentions Soralis' Math Mod, available at Planet Elder Scrolls: Math Mod. Degree/Radian conversions, Distance calculations, and the 6 basic trig functions. So xArcTan is a simple extended function call. Occasionally, there's a need for something more.įor anyone writing a script in a mod using MWSE, the basic trig functions are built in.
By limited, we mean square root ( GetSquareRoot) and distance ( GetDistance) from one object to another (with some substantial limitations). Outfile:write("%%% calendar for the year ".year.", produced by the lua script\n%%% a on ".os.date().Morrowind comes with a very limited math library. Outfile = io.open("kalender".year.".tex","w") If juliansunday + 39 120 then ascensionday,ascensionmonth = (juliansunday - 81),5 If juliansunday + 60 151 then corpusday,corpusmonth = (juliansunday - 91),6 If juliansunday + 50 151 then pentecostmonday,pentecostmonth = (juliansunday - 101),6 If juliansunday + 39 121 then ascensionday,ascensionmonth = (juliansunday - 82),5 If juliansunday + 60 152 then corpusday,corpusmonth = (juliansunday - 92),6 If juliansunday + 50 152 then pentecostmonday,pentecostmonth = (juliansunday - 102),6 If eastersundaymonth = 4 then juliansunday = 91 + eastersundayĮlseif eastersundaymonth = 3 then juliansunday = 60 + eastersunday endĮlse if eastersundaymonth = 4 then juliansunday = 90 + eastersundayĮlseif eastersundaymonth = 3 then juliansunday = 59 + eastersunday end Goodfriday,goodfridaymonth = (eastersunday - 2),eastersundaymonthĮlse goodfriday,goodfridaymonth = (eastersunday + 29),(eastersundaymonth - 1) now, calculate other Christian holidays which depend on Easter Sunday calculate easter sunday, according to Meeus/Jones/Butcher
Neither the lua code nor the TeX code is particularly beautiful (hey, this was my first day with lua), but it may be interesting for someone out there.
We have a simple version in black and white which we print on colored paper and into which real pictures are glued, and a digital version which we send to friends via e-mail where the pages of the typeset pdf have colored backgrounds and the pictures are included.
The names of the months are in German, but that should be easy to modify.
The result will be a calendar for the year XXXX, with every month on one page Sundays and German official holidays are in boldface the first day of the week is Monday. This file can then be typeset with ConTeXt. You invoke the script from the command line: lua a XXXX, and it will produce a file kalenderXXXX.tex, where XXXX is a number between 19. Without the convenience of a precooked date module, I had to do all the calculations of holidays and days of the week myself, taking my cues mostly from wikipedia, but it was relatively easy. Then, I tried to achieve the same result with a lua script. I first did it in perl, with the Date::Calc module. There is a number of precooked scripts to produce various calendars for LaTeX, but nothing for ConTeXt, as far as I could see. Of course, I wanted to do that with ConTeXt. The background: we produce a calendar with pictures of our kids every year. I also wanted to get to know a bit more about lua.
I decided not to spoil the first day of the new year by doing real work.