Page 1 of 1
stock Item, changeItemsWeight.
Posted: 14 January 2021, 21:44
by RicardoRix
I couldn't get this to work:
this.stTableCards.changeItemsWeight( { card_type : parseInt(card.location_arg) } );
But if I manually change it, then it works....?
this.stTableCards.item_type[card_type].weight = parseInt(card.location_arg);
feels like I'm missing something quite basic...

Re: stock Item, changeItemsWeight.
Posted: 15 January 2021, 05:14
by Loreroth
I don't see anything obvious, are you getting a console error "unknow item type" + type?
Also deck's location_arg is an integer so shouldn't need converting?
Re: stock Item, changeItemsWeight.
Posted: 15 January 2021, 11:04
by RicardoRix
Loreroth wrote: ↑15 January 2021, 05:14
I don't see anything obvious, are you getting a console error "unknow item type" + type?
Also deck's location_arg is an integer so shouldn't need converting?
yes, I do get that message:
ly_studio.js:2 unknow item typecard_type
but card_type is a variable, and a number.
var card_type = this.getCardUniqueId(card.type, card.type_arg);
if I change it to a number, like this:
this.stTableCards.changeItemsWeight( { 2: parseInt(card.location_arg) } );
then it works, the new weight can be seen.
the location_arg is "1", and it still works (the cards are in the order I want) when I put it in via .item_type[card_type].weight, but then looking into the array every other variable is a number and mine is a string "1", so I used parseInt just to be neat and tidy

Re: stock Item, changeItemsWeight.
Posted: 15 January 2021, 12:17
by Loreroth
Ooooooohkay i know what the problem is. card_type itself is being interpreted as the name of the property that you want to set, rather than evaluating the variable.
Try
Code: Select all
this.stTableCards.changeItemsWeight( { [card_type] : parseInt(card.location_arg) } );
More info here
https://stackoverflow.com/questions/227 ... ct-literal
Re: stock Item, changeItemsWeight.
Posted: 15 January 2021, 12:57
by RicardoRix
yowser
okay. thanks.