ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator Exe Platform Trouble loading and setting texture
person icon
archangel
Registered User
Quote
2026-03-01 17:34:50

Can some one show me what I am doing wrong here:


/*
<action jsname="action_add_item_to_inventory"
description="Adds an item to the first empty inventory slot">
<property name="ItemNode" type="scenenode" />
<property name="ImageLoad" type="string" default="ArchSigil" />
</action>
*/

action_add_item_to_inventory = function () {
};

action_add_item_to_inventory.prototype.execute = function () {

//Validate inventory overlay
var inventory = ccbGetSceneNodeFromName("inventory");
if (!inventory) {
console.log("Inventory overlay not found.");
return;
}

//Validate item node
if (!this.ItemNode) {
console.log("ItemNode not assigned.");
return;
}

//Get item name
var itemName = ccbGetSceneNodeProperty(this.ItemNode, "Name");
if (!itemName || itemName === "") {
itemName = this.ItemNode.getName ? this.ItemNode.getName() : "UnknownItem";
}

//Get inventory image (Texture1)
var tex = ccbLoadTexture(this.ImageLoad);
if (!tex) {
console.log("ImageSource");
return;
}

console.log("Picking up item:", itemName);

//Loop slots
for (var i = 1; i <= 16; i++) {
var slot = ccbGetSceneNodeFromName("slot" + i);
if (!slot) continue;

var currentImage = ccbGetSceneNodeMaterialProperty(slot, 0, "Texture1");

//Empty slot found
if (!currentImage || currentImage === "") {
try {
ccbSetSceneNodeMaterialProperty(slot, 0, "Texture1", tex);
ccbSetCopperCubeVariable("slot" + i + "_item", itemName);

console.log("Added", itemName, "to slot" + i);
} catch (err) {
console.log("Error setting slot" + i, err);
}
break;
}
}
};



its not working or showing the texture, if there is a better / easier way of doing it let me know. But I need to be able to do it dynamically, not through the editor actions.

person icon
guest
Guest
Quote
2026-03-01 20:11:07

the problem with AI code is you still need to be able to read the code to understand if problems occur. do yourself a favor and learn the basics of JS and read CC's JS API. that said, maybe try copying and pasting the entire JS API documentation into the AI you are using and try again, step by step. first get it to properly print a string to CC's console using print() instead of console.log(). then move onto more advanced stuff. good luck.

person icon
archangel
Registered User
Quote
2026-03-01 21:55:46

A simple response was all that was needed. Trying to talk down on me for using ai for one behavior when everyone uses ai...

And more advanced stuff really... I built the entire VR platform CopperCube will now use for EXE and Webgl... what have you done??? Ill wait...

Im new to the exe platform I used only webgl for years so excuse me if i get some of the calls wrong....

person icon
hadoken
Registered User
Quote
2026-03-01 22:08:59

@archangel, if you give a more detailed description what scene node setup you want to use and what you want to achieve with it in detail, I will try to help.

person icon
archangel
Registered User
Quote
2026-03-01 22:43:28

Thank you @hadoken. But Nevermind Im just going to switch back to using overlays since I got that working on the platform now. I was using plane meshes for the inventory on this one.

But i already know what to do with overlays so im 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 |