Author Topic: Interchanging items in the Tools GUI  (Read 751 times)

I need to know how to swap out the tool I am currently using for a different one.

Code: [Select]
%obj.tool[%currSlot] = GknifeBrokenItem;
this arg doesnt work, how do I really do it?

Setting a variable won't set for the model. What you're doing is like writing on a delivery sheet "This package is here." without actually putting it there.

For changing the item of %obj in inventory slot %slot with hammerItem,
Code: [Select]
%obj.tool[%slot] = hammerItem.getID();
commandToClient(%obj.client, 'msgItemPickup', "", %slot, hamerItem.getID(), 1);

For changing the image held in %obj's right hand with hammerImage,
Code: [Select]
%obj.mountImage(hammerImage, 0);

I know how to remount an image. I didnt know how to replace the item. Thank you.

However, the "msgItemPickup" part plays the item pickup sound, doesnt it? Can I do this without that part of the function? I dont want the pickup sound played.
« Last Edit: February 03, 2011, 04:19:10 PM by takato14 »

Setting a variable won't set for the model. What you're doing is like writing on a delivery sheet "This package is here." without actually putting it there.
What I meant was, I wanted to change my inventory. I already change the weapon. I needed to change the item as well.

For changing the item of %obj in inventory slot %slot with hammerItem,
Code: [Select]
%obj.tool[%slot] = hammerItem.getID();
commandToClient(%obj.client, 'msgItemPickup', "", %slot, hamerItem.getID(), 1);

For changing the image held in %obj's right hand with hammerImage,
Code: [Select]
%obj.mountImage(hammerImage, 0);
Erm, it didnt work.... I changed hammerItem to GKnifeBrokenItem (as I needed) and nothing else.

Wait, you typed hameritem; I didnt realize there were 2 spots. Revising, and testing.... nope, still didnt work. What it DID do, was make my hammer the broken version of the sword. It didnt change the icon, but it was the sword. ._.

What I want to do. Ill represent with pictures.

Before breaking:

After Breaking:
« Last Edit: February 03, 2011, 08:58:22 PM by takato14 »


Code: [Select]
function player::setInventorySlot(%this, %i, %db) {
   %this.tool[%slot] = (%db = %db.getID());
   commandToClient(%this.client, 'msgItemPickup', "", %slot, %db.getID(), 1);
}

%obj.setInventorySlot(0, gKnifeBrokenItem);

Code: [Select]
function player::setInventorySlot(%this, %i, %db) {
   %this.tool[%slot] = (%db = %db.getID());
   commandToClient(%this.client, 'msgItemPickup', "", %slot, %db.getID(), 1);
}

%obj.setInventorySlot(0, gKnifeBrokenItem);
er... o.o


Code: [Select]
function player::setInventorySlot(%this, %i, %db) {
   %this.tool[%slot] = (%db = %db.getID());
   commandToClient(%this.client, 'msgItemPickup', "", %slot, %db, false);
}

%obj.setInventorySlot(0, gKnifeBrokenItem);

the msgitempickup doesnt just play the sound, it tells the client what the new item is, and which slot it is in.