inherit
246669
0
Jan 2, 2023 13:25:26 GMT -8
Philip
97
July 2017
phil82
|
Post by Philip on May 26, 2019 17:07:26 GMT -8
All the logic seems to get lost within the data. Could you possibly move the data to a google spreadsheet and simply fetch it when needed(google API), then have the plugin just take care of the logic ?
|
|
Xesna
New Member
Calamity is the touchstone of a brave mind.
Posts: 61
inherit
163376
0
May 8, 2021 20:19:53 GMT -8
Xesna
Calamity is the touchstone of a brave mind.
61
February 2011
xesna
|
Post by Xesna on May 27, 2019 5:15:34 GMT -8
All the logic seems to get lost within the data. Could you possibly move the data to a google spreadsheet and simply fetch it when needed(google API), then have the plugin just take care of the logic ? I do not comprehend your first sentence, "...logic seems to get lost within the data", when in contrary there is no lost of information. It is just not commented heavily for direction, so those who are not coding it or not sufficient in JavaScript, perhaps just the code in general will get lost indefinitely. I digress, nonetheless. As for the use of a Google Spreadsheet, there shouldn't be any need to do so given you're going to add more complexity than necessary; since the weather arrays and numbers can be easily modified to suit the needs of another roleplaying forums, such as a post-apocalyptic environment or a harsh exo-planet. I want it to be simplistic as possible for others to have the power to modify what is needed to suit their needs. And lastly, why? The logic is there, it just "looks" lengthy.
// Grab random index from that weather... if(weatherArr[ranWeather].length == 1) var weatherIndex = 0; else var weatherIndex = Math.floor((Math.random() * (weatherArr[ranWeather].length - 1)) + 1); I found a logical error in our code. I change the conditional statements for the rain chance, it worked, by the way. However, the weather gave me an undefined result and I checked to see the index giving me: 6 and 1. Thus, in the array: var weatherArr = [bkn, skc, few, sct, ovc, fg, smoke, fzra, ip, mix, raip, rasn, shra, tsra, sn, wind, nsvrtsra, dust, haze];Smoke is the 6 index, but the smoke only has one field in the array, being index of 0. However, we're given index of 1 due to the + 1 in the weatherIndex line of code. Thus, I fixed it by adding the if statement where if weatherArr[ranWeather] (i.e weatherArr[6] being translated to smoke.length) is equal to 1, then the weatherIndex is 0. Otherwise, do the normal mambo jumbo. Now, I will have to test it by changing the weatherArr[ranWeather] to smoke.length for verification on the code. I will edit it once it is confirmed. EDIT: It worked. Now, the next step is to coordinate the temperature and rain chance to the appropriate weather arrays by doing conditional statements; checking against the rain chance percentage (basically, the precipitation) to determine what weather will occur.
|
|
Xesna
New Member
Calamity is the touchstone of a brave mind.
Posts: 61
inherit
163376
0
May 8, 2021 20:19:53 GMT -8
Xesna
Calamity is the touchstone of a brave mind.
61
February 2011
xesna
|
Post by Xesna on May 31, 2019 5:39:57 GMT -8
/* // Weather Arrays... var weatherArr = [bkn, skc, few, sct, ovc, fg, smoke, fzra, ip, mix, raip, rasn, shra, tsraH, tsraC, sn, wind, nsvrtsra, dust, haze];
// Grab random index for state of weather... var ranWeather = Math.floor((Math.random() * (weatherArr.length - 1)) + 1); */
// Arid Weather Types (excluding smoke (used for dense forest), haze and dust (used for desert regions)): var aridH = [bkn, skc, few, sct, ovc, wind, fg, shra, tsraH]; var aridC = [bkn, skc, few, sct, wind, fg, sn, ip, fzra, tsraC];
// Humid Weather Types: var humidH = [bkn, skc, few, sct, ovc, wind, fg, nsvrtsra, shra, tsraH]; var humidC = [bkn, few, sct, wind, fg, nsvrtsra, sn, ip, fzra, tsraC, rasn, mix];
// If key has not been set, or day has changed, choose an array item and set key, otherwise display weather... if(pb.plugin.key('Weather').get() == undefined || pb.plugin.key('Weather').get()[0] != today) { var rainTemp, weatherArr;
// Set temperature... var temperature = (Math.floor((Math.random() * 87) + 1)).toString();
// Set cardinal direction... var windDirection = Math.floor((Math.random() * (direction.length - 1)) + 1);
// Set Wind Velocity... var windVelocity = Math.floor((Math.random() * 52) + 1).toString();
// Rain Chance... var rainChance = Math.floor((Math.random() * 100) + 1);
/* // Grab random index from that weather... if(weatherArr[ranWeather].length < 2) var weatherIndex = 0; else var weatherIndex = Math.floor((Math.random() * (weatherArr[ranWeather].length - 1)) + 1); */
// Drizzle of Superarid to Perarid if(rainChance < 21) { rainTemp = 0;
// Tundra to Arctic if(temperature < 33) weatherArr = aridC; // Tundra to Tropical else weatherArr = aridH; } // Isolated of Arid to Semi-Humid else if(rainChance < 30) { rainTemp = 1;
// Taiga to Arctic if(temperature < 38) weatherArr = aridC; // Confierous to Tropical else weatherArr = aridH; } // Scattered of Humid to Perhumid else if(rainChance < 51) { rainTemp = 2;
// Coniferous to Arctic if(temperature < 43) weatherArr = humidC; // Decidous to Tropical else weatherArr = humidH; } // Numerous of Superhumid else { rainTemp = 3;
// Decidous to Arctic if(temperature < 54) weatherArr = humidC; // Mediterranean to Tropical else weatherArr = humidH; }
var ranWeather = Math.floor((Math.random() * (weatherArr.length - 1)) + 1);
if(weatherArr[ranWeather] < 2) ranWeather = 0;
var weatherIndex = Math.floor((Math.random() * (weatherArr[ranWeather].length - 1)) + 1);
set_weather_key(today, temperature, weatherIndex, windDirection, windVelocity, rainTemp, rainChance, ranWeather, weatherArr); } else { // Get weather array for easy access... var weather = pb.plugin.key('Weather').get();
var tempToday = $('<div></div>').html('<b>Temperature</b>: ' + weather[1] + '°C<br><br>'); var climate = $('<div></div>').html('<b>Weather</b>: ' + weather[8][weather[7]][weather[2]] + '<br><br>'); var windy = $('<div></div>').html('<b>Wind</b>: ' + direction[weather[3]] + ' ' + weather[4] + 'km/h<br><br>'); var rainy = $('<div></div>').html('<b>Rain</b>: ' + rainType[weather[5]] + ' ' + weather[6] + '% chance');
$('#weather_result').append(tempToday, climate, windy, rainy); }
return; }
Okay, here is the updated version and I have it working with temperature and rain chance (humidity), then correlated four different arrays based on two different categories: aridH, aridC, humidH, and humidC. H stands for hot and C, for cold (if it wasn't obvious). Anyway, it works. I am quite happy with the success of how it turned out. Now, the only issue remains where: I, as a User A, do not have the same values above from another User B. I want it where, everyone shares the same weather data, not different ones. Of course, I am speculating it is due to the User Key being Private, and thus creating unique weather ids for other users. I tried doing Forum (Super), but regular users were denied access since they were not part of staff. I am going to test User (Super) since it states, "Super user keys are sent to the browser for all users currently displayed on the page." EDIT: User (Super) did not work, or assuming so given the created test dummy account, I got the following: I got it! The Forum (Super) is what was required, however, despite the permissions stating Members & Staff, it only allowed staff, and thus from the simple change of the read permissions to Members & Staff. I believe with this, I am officially done with the weather plugin, for now. I appreciate the assistance and guidance Todge , thank you very much. <3 P.S. If you can, verify my assumption of the Forum (Super) if what I said is true. I typically guess. Also, I uploaded the plugin to the Proboards Library, once it is reviewed, it will be available for access. EDIT 2: Nevermind. I am not quite done. I need to have it where it also randomly generates more then one weather result. *face palm* Okay, I just needed to add... <div class="fade">
<a href="http://nindao.proboards.com/board/13/meteor-country">
<div align="center">
<div style="float:center;
width: 225px;
height: 40px;
background-image: url(https://i.ibb.co/khnn59V/Size.jpg);
background-position: center;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-o-border-radius: 100px;
border-radius: 100px;
border: 2px solid #444444;">
</div>
</div>
</a>
<div align="center">
<div style="font: 25pt Garamond; float:center;"> <i>Kakougakure</i><br>
<div style="font: 10pt Garamond; line-height: 100%; letter-spacing: 1px;">
<i><p id ="weather_result2"></p><br/></i>
</div>
<script type="text/javascript">
document.getElementById("weather_result2").style.fontSize = "16px";
</script>
</div>
</div>
</div>
again in the Sidebar Redux Settings plugin, but now it is sharing the same data, which is coming from the Weather plugin, so let me go do that. Okay, I am assuming if I want to change the data, I need to reinstate the randomized information and for me to do that, I need to put the conditional statement inside a function, right? EDIT 3: Most likely so, but... hm? Sorry. Doing a rubber duck right now. Do I have to change the variables into arrays, such as temperature: // We are attempting two weather results for(i = 0; i < number_of_weather_results; i++) { // Set temperature...
var temperature[i] = (Math.floor((Math.random() * 87) + 1)).toString();
... ... // Then here, we pass it in as... set_weather_key(today, temperature[i], ...); } Or do we end up doing... // We are attempting two weather results
for(i = 0; i < number_of_weather_results; i++)
{
// Set temperature...
var temperature[i] = (Math.floor((Math.random() * 87) + 1)).toString();
...
...
}
// Then here, we pass it in as...
set_weather_key(today, temperature[0], ...);
set_weather_key(today, temperature[1], ...); *I ruffle my hair* Agh!? Too many inconsistencies, I need a break. Lmao. I will be back in a couple of days and ping you Todge for assistance on multiple weather result output. For now, it works for one, which most people would love to have nonetheless. Anyway, here is the plugin in Todge: Weather Plugin
EDIT: Ignore the populate(); function and move the code into the conditional statement.
|
|
Xesna
New Member
Calamity is the touchstone of a brave mind.
Posts: 61
inherit
163376
0
May 8, 2021 20:19:53 GMT -8
Xesna
Calamity is the touchstone of a brave mind.
61
February 2011
xesna
|
Post by Xesna on Jul 15, 2019 7:31:32 GMT -8
For those of you viewing the thread, I have not made any modifications as of yet. I do plan on coordinating some time in the near future, however, I hope the plugin in itself is more than enough to satisfy your needs for a weather generator. At the moment, it is only producing one result, and I've been doing other projects besides the weather given its progression. Thank you and for those who want the plugin, message me.
|
|