Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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. |
||||
|
You can create an array using js: var itemsArray = []; Add any elements // add number13 to array (for ex. item with id 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... |
||||
|
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. |
||||
|
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 = ''; |
||||
|
|
||||
|
hi all, thanks for the info. I will try it out and see it it is suitable. thanks again |
||||
|
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 |
||||
|
check to make sure you don't have spaces in your function definition or function call. it needs to be updateInventory(); |
||||
|
and if you can't get it, I can send you an example file or something. just let me know. |
||||
|
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.... |
||||
|
thanks for the help. I THINK i can get the 'player' to hold and use the items in the list thanks again |
||||
|
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... |
||||
|
always remember complexity is evil, simplicity is the good |
|