MediaWiki talk:CookingCalc.js

Hey, to whoever locked this page, I'd like to propose an edit to the calc:

var cookingStats = null; if (cookingCalcDiv = document.getElementById('cookingCalc')) { // [0]: health, [1]: stamina, [2]:food, [3]: water, [4]: weight cookingStats = { "Raw Meat": [0.55, 0.05, 0.75, 0.05, 0.01], "Raw Prime Meat": [1.2, 0.05, 1, 0.05, 0.01], "Cooked/Jerky Meat": [0.55, 0.05, 1, 0.05, 0.01], "Cooked/Jerky Prime Meat": [1.65, 0.05, 1.45, 0.05, 0.01], "Amar/Azul/Tintoberry": [0.05, 0.05, 0.1875, 0.125, 0.01], "Mejoberry": [0.05, 0.05, 0.2625, 0.175, 0.01], "Narcoberry": [0.05, -0.5, 0.5, 0.05, 0.01], "Stimberry": [0.05, 0.625, 0.1875, -1.25, 0.01], "Seed": [0.05, 0.05, 0.05, 0.05, 0.001], "Crop": [0.275, 0.05, 0.3, 2.5, 0.01], "Rare Mushroom": [0.05, 5, 0.05, 0.05, 0.001], "Rare Flower": [0.05, 0.05, 0.05, 0.05, 0.001], "Egg": [4, 4, 4, 0.05, 0.3], "Kibble": [0.05, 15, 11.25, -5, 0.001], "Spoiled Meat": [-2.5, -1.5, 0.3125, 0.05, 0.01], "Poop": [-0.625, -0.625, 0.5, -0.625, 0.03] };   var tableRows = ''; var dropDownOptions = ''; for (var ing in cookingStats) { dropDownOptions += ' ' + ing + ' '; }

for (var i = 0; i < 8; i++) { tableRows += ' ' + dropDownOptions + '    '; }

cookingCalcDiv.innerHTML = ' ' + ' ';   for (var i = 0; i < 8; i++) { document.getElementById('cookingCalcIng' + i).selectedIndex = i;   } }

function cookingCalcChangeKind(food) { document.getElementById('cookingR2').style.textDecoration = (food ? "" : "line-through"); document.getElementById('cookingR3').style.textDecoration = (food ? "line-through" : ""); }

function calcCooking { if (cookingStats) { var results = [1, 1, 1, 1, 0.1];

var ing = 0; var ingNr = 0; var ingEl = null; var ingNrEl = null; var csEl = document.getElementById('cookingCalcCraftingSpeed'); if (csEl != null) { var cs = csEl.value / 100.0; for (var i = 0; i < 8; i++) { ingEl = document.getElementById('cookingCalcIng' + i); ingNrEl = document.getElementById('cookingCalcIngNr' + i); if (ingEl != null && ingNrEl != null) { ing = ingEl.value; ingNr = ingNrEl.value; if (cookingStats[ing] != null) { for (var j = 0; j < 4; j++) { results[j] += ingNr * cookingStats[ing][j] * (cs * 1.5625 - 0.3125); }                       results[4] += ingNr * cookingStats[ing][4]; }               }            }        }        for (var j = 0; j < 5; j++) { var rEl = document.getElementById('cookingR' + j); if (rEl != null) { rEl.innerHTML = results[j].toFixed(2); }       }    } }

It adds weight calculation, aaand pretty much just that.

Pardon the broken formatting, but it's just not possible to do better - it's a bug in MediaWiki itself. I could use the nowiki tag, but that murders newlines. Just view the source.


 * Commented out to avoid breaking the page. -- Mr Pie 5  (talk) 06:35, 9 April 2016 (UTC)


 * Hi, thanks for the suggestion! I added it to the script. Javascript is always locked for users to prevent abuse. For the formatting you should always use the nowiki-tag. To write code insert a single space before the nowiki-tag. I don't see a bug there, mediawiki just interprets the tags provided.--Cadaeib (talk) 12:05, 9 April 2016 (UTC)