Ikariam kChen Overview

By kchen Last update Feb 18, 2009 — Installed 346,353 times.

Wine Calculation Update

in
Subscribe to Wine Calculation Update 10 posts, 4 voices



LinusGold User

Hey,
This is my first post on this forum and the first time I worked on a grease monkey script but it seems to work so far. In order for it to work you need to visit the tavern first.

To make this update work edit the script and do a search for "function storeWineUsage" excluding the quotation marks, then replace that code with the following.

if (/view=tavern/.test(document.URL)) {
function storeWineUsage() {
try {
var n = document.getElementById("wineAmount");
var city_id = getNode_value("//form[@id='wineAssignForm']/input[@type='hidden' and @name='id']");
var city = getCity(city_id);
city.wineUsage = tavernWineUsage[n.selectedIndex];
setVar("config", serialize(config));
} catch (e) {
log("Hiba: "+e);
}
}
var n = getNode("//form[@id='wineAssignForm']//*[@type='submit']");
n.addEventListener("click", storeWineUsage, false);
var n = document.getElementById("wineAmount");

wineUsage = tavernWineUsage[n.selectedIndex];
var cellarLevel = getArrValue(res.buildings["vineyard"], "level", "-");
wineSave = wineUsage * cellarLevel;
wineSave = wineSave / 100;
wineUsage = wineUsage - wineSave;

res.wineUsage = wineUsage ;
}

Then you also need to update the tavern values, just do a search for tavernWineUsage it will look similar to the following line just with different numbers.

var tavernWineUsage = [0, 4, 8, 13, 18, 24, 30, 37, 44, 51, 60, 68, 78, 88, 99, 110, 122, 136,150,165,180,197,216,235,255];

Hope this helps, Any questions just ask.
Linus

 
oliezekat Scriptwright

Study "Ikariam v3 Empire Board" script (based on "Alarm & Overview" like kChen) to find how to detect saved wine (by bonus building) under Ikariam v0.3.0 ;o)

NB: I not use same way to detect wine saved to support future behaviors ; several vineyard per cities, new wonders, etc. Think to future ^^

 
LinusGold User

@oliezekat
I did actually download your script but it didn't take the wine savings off.
How did you attempt to do it?

 
oliezekat Scriptwright

LinusGold, you may disable Alarm & Overview, kChen, or similar script... Or download last release 1.1.1 ;o)

My function to get saved wine from tavern page :

    function getSavedWine() {
      try {
        var n = document.getElementById("savedWine");
		if ((n.innerHTML != '& nbsp ;') && (Trim(n.innerHTML) != ''))
			{
			return Math.round(parseFloat(n.innerHTML));
			}
		else return 0;
       } catch (e) {
        log("Hiba: "+e);
		return 0;
      }

NB: remove spaces into '& nbsp ;' string

 
caaveiro User

oliezekat

Idont test you script but .

the modification pourpose for linusgold its OK.

Working 100 % . in the orginal script the best version.

 
LinusGold User

@oliezekat
Yours was the only script running. And I pretty sure i got the latest one.
That doesnt really tell me anything about how you did it? document.getElementById("savedWine") is the method that you have used but you didnt tell how that method works? 'document' is just what has been used to store the information, what was used to calculate how to the savedWine when it was placed into the 'document'

@caaveiro
Thats good to hear, glad to help

 
HaxLi Scriptwright

I wonder what exactly your script changes.. couldn't spot the difference, except that in tavern it do not show the calculation. Maybe I need to reset Data x]

I'd like to suggest about Wine calculation in city table:

Now it shows:

__________Wine____________________
1,523	-17	+74 //in wine city
393	-11	1D //not in wine city
__________________________________

Please calculate it to +57 in first cell (74-17=57), and in another the Day value till full.

Thank you..

 
oliezekat Scriptwright

@caaveiro: linusgold method work fine but could be break while GF update game engine with new features or settings...

@HaxLi: hum, why not display this into tooltip while mouse over ? It's usefull to know how many wine we lost and won per cities ;o)

 
caaveiro User

oliezekat: It always happens whenever they update the game.

I believe that the update pourpose by linus is very good.

And the script what you say ,, only ist a copy of Kchen overview.

LinusGold :I have found a small mistake, when you do not have vineyard, on having entered the tavern, there is a mistake and does not give the correct information of quantity stored of wine and consumption. With this small modification I have arranged it :

wineUsage = tavernWineUsage[n.selectedIndex];
var cellarLevel = getArrValue(res.buildings["vineyard"], "level", "-");
if (cellarLevel >=0) {
wineSave = wineUsage * cellarLevel;
wineSave = wineSave / 100;
wineUsage = wineUsage - wineSave;
res.wineUsage = wineUsage ;
} else {

res.wineUsage = wineUsage ;
}

Thats modification if you dont have vineyard ,dont calculate the vinesave , then the mistakes dont apear. beacuse when yo dont have vineyard the level is - , and his create a fail .

Sorry , for my very bad english writing , but im from spain.

 
LinusGold User

caaveiro
thanks man. I hadnt thought of that

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel