stock Item, changeItemsWeight.

Game development with Board Game Arena Studio
Post Reply
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

stock Item, changeItemsWeight.

Post 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... :oops:
User avatar
Loreroth
Posts: 18
Joined: 05 August 2014, 07:28

Re: stock Item, changeItemsWeight.

Post 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?
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: stock Item, changeItemsWeight.

Post 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 ;)
User avatar
Loreroth
Posts: 18
Joined: 05 August 2014, 07:28

Re: stock Item, changeItemsWeight.

Post 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
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: stock Item, changeItemsWeight.

Post by RicardoRix »

yowser :shock:

okay. thanks.
Post Reply

Return to “Developers”