moonPhase: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3dev |= Game name |1.57|= Game version ______________...")
 
m (Some wiki formatting)
 
(62 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3dev |= Game name
|game1= arma3
|version1= 1.58


|1.57|= Game version
|gr1= Environment
____________________________________________________________________________________________


| Returns the phase of the in-game Moon on the given date in range 0...1, where 0 - new Moon, 1 - full Moon. According to this command the fullest Moon in Arma 3 at midnight is on <tt>[[setDate]] [4804,7,13,0,0];</tt>|= Description
|descr= Returns the phase of the in-game Moon on the given date.
____________________________________________________________________________________________
According to this command, the fullest Moon in {{arma3}} at midnight is on <sqf inline>setDate [4804, 7, 13, 0, 0];</sqf>.
Use the {{Link|Arma 3: Utilities#Moon Phases|Moon Phase Utility}} to find out a scenario date with desired moon.


| '''moonPhase''' date |= Syntax
|s1= [[moonPhase]] date
|p1= date: [[Array]] - required date in [[date]] format |= Parameter 1
 
| [[Number]]|= Return value
|p1= date: [[Array]] format [[Date]]
____________________________________________________________________________________________
 
 
|r1= [[Number]] in 0..1 range - 0 = new Moon, 1 = full Moon
|x1= <code>_currentMoonPhase = [[moonPhase]] [[date]];</code> |= Example 1
 
|x2= <code>// Returns array of dates for given year when moon is at its fullest
|x1= <sqf>private _currentMoonPhase = moonPhase date;</sqf>
 
|x2= <sqf>
// Returns array of dates for given year when moon is at its fullest
fnc_fullMoonDates =  
fnc_fullMoonDates =  
{
{
[[private]] _year = [[param]] [0, 2035];
private _year = param [0, 2035];
[[private]] ["_date", "_phase", "_fullMoonDate"];
private ["_date", "_phase", "_fullMoonDate"];
[[private]] _fullMoonPhase = 1;
private _fullMoonPhase = 1;
[[private]] _day = 1 / 365;
private _waxing = false;
[[private]] _waxing = [[false]];
private _fullMoonDates = [];
[[private]] _fullMoonDates = [];
for "_i" from dateToNumber [_year, 1, 1, 0, 0] to dateToNumber [_year, 12, 31, 23, 59] step 1 / 365 do
[[for]] "_i" [[from]] -_day [[to]] [[dateToNumber]] [_year, 12, 31, 23, 59] [[step]] _day [[do]]
{
{
_date = [[numberToDate]] [_year, _i];
_date = numberToDate [_year, _i];
_phase = [[moonPhase]] _date;
_phase = moonPhase _date;
[[call]]
 
call
{
{
[[if]] (_phase > _fullMoonPhase) [[exitWith]]
if (_phase > _fullMoonPhase) exitWith
{
{
_waxing = [[true]];
_waxing = true;
_fullMoonDate = _date;
_fullMoonDate = _date;
};
};
[[if]] (_waxing) [[exitWith]]
 
if (_waxing) exitWith  
{
{
_waxing = [[false]];
_waxing = false;
_fullMoonDates [[pushBack]] _fullMoonDate;
_fullMoonDates pushBack _fullMoonDate;
};
};
};
};
_fullMoonPhase = _phase;
_fullMoonPhase = _phase;
};
};
_fullMoonDates
 
_fullMoonDates;
};
};


//set random full moon date in year 1970
//set random full moon date in year 1970
[[setDate]] [[selectRandom]] (1970 [[call]] fnc_fullMoonDates);</code> |= Example 2
setDate selectRandom (1970 call fnc_fullMoonDates);
 
</sqf>
____________________________________________________________________________________________
 
| [[moonIntensity]], [[sunOrMoon]]|= See also


|seealso= [[moonIntensity]] [[sunOrMoon]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 16:57, 27 July 2023

Hover & click on the images for description

Description

Description:
Returns the phase of the in-game Moon on the given date. According to this command, the fullest Moon in Arma 3 at midnight is on setDate [4804, 7, 13, 0, 0];. Use the Moon Phase Utility to find out a scenario date with desired moon.
Groups:
Environment

Syntax

Syntax:
moonPhase date
Parameters:
date: Array format Date
Return Value:
Number in 0..1 range - 0 = new Moon, 1 = full Moon

Examples

Example 1:
private _currentMoonPhase = moonPhase date;
Example 2:
// Returns array of dates for given year when moon is at its fullest fnc_fullMoonDates = { private _year = param [0, 2035]; private ["_date", "_phase", "_fullMoonDate"]; private _fullMoonPhase = 1; private _waxing = false; private _fullMoonDates = []; for "_i" from dateToNumber [_year, 1, 1, 0, 0] to dateToNumber [_year, 12, 31, 23, 59] step 1 / 365 do { _date = numberToDate [_year, _i]; _phase = moonPhase _date; call { if (_phase > _fullMoonPhase) exitWith { _waxing = true; _fullMoonDate = _date; }; if (_waxing) exitWith { _waxing = false; _fullMoonDates pushBack _fullMoonDate; }; }; _fullMoonPhase = _phase; }; _fullMoonDates; }; //set random full moon date in year 1970 setDate selectRandom (1970 call fnc_fullMoonDates);

Additional Information

See also:
moonIntensity sunOrMoon

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note