ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator text arrays
person icon
brian smith
Guest
Quote
2024-11-20 12:55:24

i want to write an array to hold the equipment held by the player. (this is a D&D type game).
how can I set it up in Coppercube and access induvial elements of the list.
Is it possible to write it in JS and access the elements in Coppercube.

person icon
okeoke
Registered User
Quote
2024-11-20 13:58:45

You can create an array using js:
var itemsArray = [];

Add any elements
// add number13 to array (for ex. item with id 13)
itemsArray.push(13);

Remove element with index 3
itemsArray.splice(3, 1)

Access individual elements by index. Fx. 0:
 var firstElement = itemsArray[0];

https://developer.mozilla.org/en...

person icon
brian
Guest
Quote
2024-11-20 19:13:21

thanks for the info:
I assume this is in JS
I can produce a 2dOverlay box activated by the F1 key,
I want to print elements of the array but cannot seem to get it to work.
I have used the $-$ system to print single values that have been preset and can be altered by overprinting, but I do not know how the print elements of a text array.

person icon
okeoke
Registered User
Quote
2024-11-20 19:27:42

It will not work with built-in action. I don't think there is any way to interact with arrays using the built-ins. You also use js to set text like:
var text = '';
for (var i =0; i < array.length; i++) {
text+= array[i] + '\r\n';
}
ccbSetSceneNodeProperty(textNode, 'Text', text);


person icon
meh
Guest
Quote
2024-11-20 20:20:05

embedded external image
🔎︎


person icon
brian
Guest
Quote
2024-11-20 21:45:54

hi all,
thanks for the info. I will try it out and see it it is suitable.
thanks again

person icon
brian
Guest
Quote
2024-11-20 23:19:41

Hi Meh,
thanks for the example. i understand how it would work but (possibly due to my error) when I run the program I get a error message stating ' update Inventory' not defined.
i have checked all the typing and it is exactly the same as your example.
Any ideas?
Brian

person icon
meh
Guest
Quote
2024-11-20 23:33:40

check to make sure you don't have spaces in your function definition or function call. it needs to be updateInventory();

person icon
meh
Guest
Quote
2024-11-20 23:36:29

and if you can't get it, I can send you an example file or something. just let me know.

person icon
meh
Guest
Quote
2024-11-21 00:33:36

went ahead and made an example project with a couple extra bits in it. note: this is just the foundation of an inventory system... lots of ways you can improve and expand upon it.

https://files.catbox.moe/8qur19....

person icon
brian
Guest
Quote
2024-11-22 17:37:11

thanks for the help. I THINK i can get the 'player' to hold and use the items in the list
thanks again

person icon
meh
Guest
Quote
2024-11-23 03:15:20

well, if you can't do it, just ask and I will help you. here's a hint: look up the term 'callback'... use this with a function called useItem... and the one thing becomes the many...

person icon
meh
Guest
Quote
2024-11-23 03:19:49

always remember complexity is evil, simplicity is the good


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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