From 3760cbf3c2d999e0c854f0a2c41e10e6ec2c1aa5 Mon Sep 17 00:00:00 2001 From: Kaan Soral Date: Thu, 16 Feb 2017 01:08:50 +0300 Subject: [PATCH] Update simple_compound.js --- examples/simple_compound.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/simple_compound.js b/examples/simple_compound.js index 467ee1a..abf89e3 100644 --- a/examples/simple_compound.js +++ b/examples/simple_compound.js @@ -10,13 +10,22 @@ function locate_item(name) return -1; } +function return_item(name) +{ + for(var i=0;i<42;i++) + { + if(character.items[i] && character.items[i].name==name) return character.items[i]; + } + return -1; +} + setInterval(function(){ // if(character.bank) return; loops+=1; if(!(loops%50)) // Every 50 loops, stock scrolls { - if(locate_item("cscroll0")==-1 || locate_item("cscroll0").q<200) buy("cscroll0",200); - if(locate_item("cscroll1")==-1 || locate_item("cscroll1").q<30) buy("cscroll1",30); + if(locate_item("cscroll0")==-1 || return_item("cscroll0").q<200) buy("cscroll0",200); + if(locate_item("cscroll1")==-1 || return_item("cscroll1").q<30) buy("cscroll1",30); } var done=false; for(var i=0;i<42;i++)