So i have another issue with a script on a custom sheet i have made. i cant get this script to generate the correct number the value needs to go up as the qty goes up. but i cant get it to do that what am i doing wrong? Is it because the qty can be changed with another button? Here is the script <script type="text/worker"><!-- Purchase Cost -->
on('sheet:opened change:farm_qty', function (value) {
getAttrs(['farm_qty'], function (value) {
const farm_qty = +values.farm_qty || 0;
const farm_price = 10 * farm_qty;
let farm_purchase = farm_price;
let farm_stone = 10;
let farm_wood = 10;
let farm_metal = 10;
let farm_citizen = 1;
let farm_coin = 1;
let farm_food = 0;
setAttrs({farm_purchase: farm_purchase});
setAttrs({farm_stone : farm_stone});
setAttrs({farm_wood : farm_wood});
setAttrs({farm_metal : farm_metal});
setAttrs({farm_citizen : farm_citizen});
setAttrs({farm_coin : farm_coin});
setAttrs({farm_food : farm_food});
});
});
</script> Here is the input lines. <input name="attr_farm_name" class="text110" type="text" value="Farm I">
<button name= "act_farm_d" class="button1" type="action">-</button>
<input name="attr_farm_qty" class="text025" type="text" value="0">
<button name= "act_farm_p" class="button1" type="action">+</button> Here is the script for the + button <script type="text/worker"><!-- Purchase Button -->
on('clicked:farm_p', function() {
getAttrs(['farm_qty','coin_stock','farm_purchase','farm_wood','wood_stock','farm_stone','stone_stock','farm_metal','metal_stock'], function(values) {
<!-- Qty Up -->
const farm_qty = +values.farm_qty || 0;
const new_farm_qty = farm_qty +1;
<!-- Coin Cost -->
const farm_purchase = +values.farm_purchase || 0;
const coin_stock = +values.coin_stock || 0;
const new_coin_stock = coin_stock - farm_purchase;
<!-- Qty Metal -->
const farm_metal = +values.farm_metal || 0;
const metal_stock = +values.metal_stock || 0;
const new_metal_stock = metal_stock - farm_metal;
<!-- Qty Wood -->
const farm_wood = +values.farm_wood || 0;
const wood_stock = +values.wood_stock || 0;
const new_wood_stock = wood_stock - farm_wood;
<!-- Qty Stone -->
const farm_stone = +values.farm_stone || 0;
const stone_stock = +values.stone_stock || 0;
const new_stone_stock = stone_stock - farm_stone;
setAttrs({farm_qty: new_farm_qty});
setAttrs({coin_stock: new_coin_stock});
setAttrs({metal_stock: new_metal_stock});
setAttrs({wood_stock: new_wood_stock});
setAttrs({stone_stock: new_stone_stock});
});
});
</script> Here is a - button <script type="text/worker"><!-- Destroy Button -->
on('clicked:farm_d', function() {
getAttrs(['farm_qty'], function(values) {
const farm_qty = +values.farm_qty || 0;
const new_farm_qty = farm_qty -1;
setAttrs({farm_qty: new_farm_qty});
});
});
</script>