0) div.removeChild(div.childNodes[0]);
div.style.left = "0px";
for(j in arr)
{
if(!(!isNaN(parseFloat(arr[j])) && isFinite(arr[j]))) continue;
var it = ItemManager.get(arr[j]);
if(it === null || it.name === null || it.name =='undefined')
{
console.error("TW-Tamagotchi Script: Item " + arr[j] + " not found");
continue;
}
var bagItem = Bag.getItemByItemId(arr[j]);
var itemCounts = (bagItem !== null && typeof bagItem !=='undefined' && bagItem.count != 'undefined') ? bagItem.count : 0;
var divi = document.createElement("div");
divi.className = "item item_inventory not_upgradeable hasMousePopup";
var img = document.createElement("img");
img.className = "tw_item item_inventory_img dnd_draggable";
img.setAttribute("src", "https://westit.innogamescdn.com/" + it.image );
if(itemCounts > 0) img.addEventListener("click", this.createFunc(it.action));
var tt = new ItemPopup(it,{show_buffs:false,show_compare:false,show_alreadyown:false,traderCharge:false,show_setboni:true,character:this.character,show_sell_price:true,show_lifetime:false,show_cooldown:true});
tt.bindTo(img);
divi.appendChild(img);
var spa = document.createElement("span");
spa.className = "count";
spa.setAttribute("style", "display:block;");
spa.appendChild(document.createTextNode(itemCounts));
divi.appendChild(spa);
div.appendChild(divi);
}
},
init : function() {
this.riposo.push(1971000); // calumet 100%R
this.riposo.push(1997000); // arrosto 100%R 100%L
this.riposo.push(2130000); // tè maté 100%R 20%L 20%D
this.riposo.push(2129000); // guaranà 50%R 10%L 10%D
this.riposo.push(2128000); // caffé 25%R 5%L 5%D
this.riposo.push(1890000); // tè 20%R
this.riposo.push(1969000); // whiskey invecchiato 20%R
this.riposo.push(1970000); // torta di ciliegie 20%R
this.riposo.push(2294000); // colore blu 15%R
this.riposo.push(1928000); // sacco a pelo 15%R 15%L
this.riposo.push(1898000); // acqua di rosa 15%R 25%V
this.riposo.push(1943000); // fagioli cotti 10%R
this.riposo.push(2358000); // salsiccia 10%R 10%V
this.riposo.push(2296000); // fuoco artificio 10%V 10%R
this.riposo.push(185205000); // uovo pasqua 10%R 10%V
this.riposo.push(255000); // insalata pomodori 10%R 10%L
this.riposo.push(1892000); // liquore fruttato 10%R 15%V
this.riposo.push(1985000); // liquore squisito 10%R 15%D
this.riposo.push(1937000); // zaino 5%R
this.vita.push(2117000); // liquido 75%V
this.vita.push(1974000); // elisir 50%V
this.vita.push(2116000); // linfa 25%V
this.vita.push(2295000); // colore bianco 20%V
this.vita.push(2357000); // crauti 20%V
this.vita.push(1898000); // acqua di rosa 15%R 25%V
this.vita.push(185204000); // uovo pasqua 20%V
this.vita.push(1892000); // liquore fruttato 10%R 15%V
this.vita.push(2358000); // salsiccia 10%R 10%V
this.vita.push(2296000); // fuoco artificio 10%V 10%R
this.vita.push(185205000); // uovo pasqua 10%R 10%V
this.vita.push(1883000); // medicina stomaco 10%V
this.lavoro.push(1997000); // arrosto 100%R 100%L
this.lavoro.push(1934000); // pomello da sella 30%L 30%D
this.lavoro.push(1984000); // lozione capelli 20%L
this.lavoro.push(185200000); // uovo pasqua 15%L
this.lavoro.push(1891000); // tabacco 25%L
this.lavoro.push(2130000); // tè maté 100%R 20%L 20%D
this.lavoro.push(2291000); // fuoco artificio 15%V
this.lavoro.push(1928000); // sacco a pelo 15%R 15%L
this.lavoro.push(2129000); // guaranà 50%R 10%L 10%D
this.lavoro.push(255000); // insalata pomodori 10%R 10%L
this.lavoro.push(1939000); // sigarette con filtro 7%L 7%D
this.lavoro.push(2128000); // caffé 25%R 5%L 5%D
this.duello.push(1934000); // pomello da sella 30%L 30%D
this.duello.push(2130000); // tè maté 100%R 20%L 20%D
this.duello.push(185202000); // uovo pasqua 15%D
this.duello.push(2294000); // colore rosso 15%D
this.duello.push(1985000); // liquore squisito 10%R 15%D
this.duello.push(1882000); // spazzola tubolare 10%D
this.duello.push(1952000); // sacco del cibo 10%D
this.duello.push(1988000); // fondina 10%D
this.duello.push(2129000); // guaranà 50%R 10%L 10%D
this.duello.push(1939000); // sigarette con filtro 7%L 7%D
this.duello.push(2128000); // caffé 25%R 5%L 5%D
},
},
localeManager: {
localeDefault: 'en_US',
localeScript: 'en_US',
getMsg: function(msg) {
if(undefined !== this.languages[this.localeScript][msg]) return this.languages[this.localeScript][msg];
if(undefined !== this.languages[this.localeDefault][msg]) return this.languages[this.localeDefault][msg];
return '';
},
checkLanguages: function() {
var langs = Object.keys(this.languages), messages = Object.keys(this.languages[this.localeDefault]), that = this;
$.each(messages, function(i, msg) {
$.each(langs, function(j, lang) {
if(!that.languages[lang].hasOwnProperty(msg)) console.log('Missing '+lang+'.'+msg);
else if(typeof that.languages[that.localeDefault][msg] == "object") {
$.each(Object.keys(that.languages[that.localeDefault][msg]), function(k, msg2) {
if(!that.languages[lang][msg].hasOwnProperty(msg2)) console.log('Missing '+lang+'.'+msg+'.'+msg2);
});
}
});
});
$.each(langs, function(i, lang) {
$.each(Object.keys(that.languages[lang]), function(j, msg) {
if(!messages.includes(msg)) console.log('Obsolete message '+lang+'.'+msg);
else if(typeof that.languages[lang][msg] == "object") {
$.each(Object.keys(that.languages[lang][msg]), function(j, msg2) {
if(!that.languages[that.localeDefault][msg].hasOwnProperty(msg2)) console.log('Obsolete message '+lang+'.'+msg+'.'+msg2);
});
}
});
});
},
setLocale: function(localeSelected) {
this.localeScript = (undefined !== this.languages[localeSelected]) ? localeSelected : this.localeDefault;
},
languages: {
en_US: {
description: 'The West - Tamagotchi PG
Add a Tamagothi Toolbar over your PG
You will be able to use consumables ordered by type:
- Energy
- Live
- Working points
- Duels points
Credits: '+scriptCredits+'
',
version: 'version',
version_checkFailed: 'Unable to check for updates',
version_checkManual: 'Check manually',
version_ok: 'You already have the latest version',
version_upgrade: 'A new version is available. Do you want to upgrade now?',
refresh: 'Refresh',
menu_live : 'Live points',
menu_energy : 'Energy points',
menu_work : 'Work motivation',
menu_duel: 'Duel motivation',
menu_speed: 'Speed',
menu_special: 'Special items',
},
it_IT: {
description: 'The West - Tamagotchi PG
Aggiungi un menu in stile Tamagotchi al tuo PG
Potrai usare in modo semplice i consumabili ordinati per:
- Riposo
- Vita
- Motivazione lavoro
- Motivazione duello
Credits: '+scriptCredits+'
',
version: 'versione',
version_checkFailed: 'impossibile cercare aggiornamenti',
version_checkManual: 'Cerca manualmente',
version_ok: 'Possiedi la versione più recente',
version_upgrade: 'E\' disponibile una nuova versione, aggiornare ora?',
refresh: 'Aggiorna',
menu_live : 'Punti vita',
menu_energy : 'Energia lavoro',
menu_work : 'Motivazione lavoro',
menu_duel: 'Motivazione duello',
menu_speed: 'Velocità',
menu_special: 'Oggetti speciali',
}
},
},
script: {
api: null,
listeningSignal: 'game_config_loaded',
loaded: false,
init: function() {
var that = this;
if(this.loaded) return false;
EventHandler.listen(this.listeningSignal, function() {
that.init();
return EventHandler.ONE_TIME_EVENT;
});
if(!!(Game && Game.loaded)) {
this.loaded = true;
TamagotchiPG.localeManager.setLocale(Game.locale);
this.api = TheWestApi.register(scriptObject, scriptName, '0.4', Game.version.toString(), scriptAuthor, URL_INSTALL);
this.api.setGui(TamagotchiPG.localeManager.getMsg('description'));
TamagotchiPG.powerItems.init();
TamagotchiPG.toolbar.init();
var j;
AnimatedCharacter.getElement()[0].addEventListener("click", function(e) {
e.preventDefault();
if(TamagotchiPG.toolbar.div1 !== null)
{
for(var h1 in TamagotchiPG.toolbar.div1.childNodes)
{
if(e.target == TamagotchiPG.toolbar.div1.childNodes[h1]) return TamagotchiPG.toolbar.closeDefault();
for(var h2 in TamagotchiPG.toolbar.div1.childNodes[h1].childNodes)
{
if(e.target == TamagotchiPG.toolbar.div1.childNodes[h1].childNodes[h2]) return TamagotchiPG.toolbar.closeDefault();
for(var h3 in TamagotchiPG.toolbar.div1.childNodes[h1].childNodes[h2].childNodes)
{
if(e.target == TamagotchiPG.toolbar.div1.childNodes[h1].childNodes[h2].childNodes[h3]) return TamagotchiPG.toolbar.closeDefault();
}
}
}
AnimatedCharacter.getElement()[0].removeChild(TamagotchiPG.toolbar.div1);
TamagotchiPG.toolbar.div1 = null;
TamagotchiPG.powerItems.subdivs = [];
return TamagotchiPG.toolbar.closeDefault();
}
var div3 = document.createElement("div");
div3.setAttribute("style", "width:305px;height:60px;display:block;margin-left:20px;overflow:hidden;");
var div2 = document.createElement("div");
div2.setAttribute("style", "width:3000px;max-height:60px;padding-left:0px;left:0px;position:relative;");
div3.appendChild(div2);
TamagotchiPG.toolbar.div1 = document.createElement("div");
TamagotchiPG.toolbar.div1.setAttribute("style", "width:342px;border-radius:10px;overflow:hidden;height:60px;display:block;left:" + AnimatedCharacter.getElement()[0].style.left + ";top:" + AnimatedCharacter.getElement()[0].style.top + ";transform:translate(-120px,-146px);");
TamagotchiPG.toolbar.div1.className = "work hasMousePopup";
var divbg = document.createElement("div");
divbg.setAttribute("style", "background-color:black;opacity:0.3;width:342px;height:60px;position:absolute;left:0px;top:0px;");
TamagotchiPG.toolbar.div1.appendChild(divbg);
var table = document.createElement("div");
table.setAttribute("style","cursor:pointer;display:block;position:absolute;font-size:12px;margin-left:5px;margin-top:2px;float:left;width:16px;");
for(var k=0;k<4;k++)
{
var td = document.createElement("div");
var imgi = document.createElement("img");
td.setAttribute("style","width:15px;height:14px;opacity:0.5;margin:0px;display:block;background-size:cover;");
td.addEventListener("click", TamagotchiPG.powerItems.createFunc2(k, div2));
imgi.setAttribute("src", TamagotchiPG.toolbar.menuicons[k]);
imgi.setAttribute("style", "width:10px;height:10px;margin:1px;margin-left:2px;");
imgi.className = "tw_item item_inventory_img dnd_draggable";
imgi.setAttribute("title", TamagotchiPG.toolbar.menutitles[k]);
td.appendChild(imgi);
td.className = "item item_inventory title hasMousePopup";
TamagotchiPG.powerItems.subdivs.push(td);
table.appendChild(td);
}
TamagotchiPG.toolbar.div1.appendChild(table);
table = document.createElement("div");
table.setAttribute("style","cursor:pointer;font-size:18px;position:absolute;display:block;margin-left:324px;width:16px;");
for(k=0;k<2;k++)
{
var tx = document.createElement("div");
tx.setAttribute("style","width:15px;height:22px;color:white;padding:0px;margin-"+(k===0?"top":"bottom")+":4px;padding-top:3px;display:block;background-size:cover;text-align:center;");
tx.addEventListener("click", k===0?function(){TamagotchiPG.powerItems.move(+5,div2);}:function(){TamagotchiPG.powerItems.move(-5,div2);});
tx.appendChild(document.createTextNode([">","<"][k]));
tx.className = "item item_inventory title hasMousePopup";
table.appendChild(tx);
}
TamagotchiPG.toolbar.div1.appendChild(table);
TamagotchiPG.powerItems.showItems(0, TamagotchiPG.powerItems.riposo, div2);
TamagotchiPG.toolbar.div1.appendChild(div3);
AnimatedCharacter.getElement()[0].appendChild(TamagotchiPG.toolbar.div1);
return TamagotchiPG.toolbar.closeDefault();
});
}
},
},
};
$(function() { try { TamagotchiPG.script.init(); } catch(x) { console.trace(x); } });
});