Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Final steps - Inventory Arrays

Robo
Guest
Quote
2019-06-21 11:49:40

For a newb I have managed to get this javascript array in CC working but unsure how to do the final step to translate the results to populate the 2D overlays I have setup in my inventory screen(called - slt1, slt2, slt3 etc):

This works:

const invMe= [
{name: 'Water bottle', qty: 1, group: 'food', regen: 6, condition: 0.9, weight: 0.7},
{name: 'Bandage', qty: 0, group: 'heal', regen: 2, condition: 0.8, weight: 0.1},
{name: 'Medkit', qty: 2, group: 'heal', regen: 7, condition: 0.8, weight: 0.3}
];



//WORKING - filter a group like name, qty, group, regen etc
const filtercategrory1 = invMe.filter(function(list) {
if(list.group === 'heal') {
print(list.name);
return true;
}
});

//WORKING - filter results within a category like name, qty, group, regen etc
const filtercategory2 = invMe.filter(function(list) {
if(list.qty >= 1) {
print(list.weight);
return true;
}
});


I'm fairly sure you need to allocate the index of each result of the query wanted to one 2D overlay each. Im just not sure how to do that... anyone please ??


Robo
Guest
Quote
2019-06-21 12:03:15

NOTE - the first two 2D overlays (slt1, slt2 etc) need to know what the item is in index 0 & 1 etc and show the picture accordingly.

I suspect I need another grouping like "nu" in my array to attach this number to each 2d overlay so that showing the appropriate picture will be easier to lookup like.....texture1.png and texture2.png etc...

any thoughts on this also ?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact