Author Topic: Get player's equipped item slot to define %slot  (Read 1516 times)

Basically, I've been struggling for the past week or so to set up iron sights within Rykuta's weapon system. The issue has been getting ammo to properly transfer between the base and ADS images.
With help from Rykuta, I've gotten this far:

function R101CADSImage::onMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%slot].Image];
   Parent::onMount(%this,%obj,%slot);
   %obj.pushDatablock(SlowArmor.getID());
   %obj.clipAmmo[%obj.tool[%slot].Image] = %newAmmo;
}

function R101CADSImage::onUnMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%slot].Image];
   Parent::onUnMount(%this,%obj,%slot);
   %obj.popDatablock(SlowArmor.getID());
   %obj.clipAmmo[%obj.tool[%slot].Image] = %newAmmo;
}


What I need to do is define %slot as being the equipped item, but Rykuta didn't remember exactly how this is done. Any help?

%this is the image
%obj is the player it's mounting to
%slot is the slot the image is being mounted to on the player
« Last Edit: September 01, 2014, 11:24:40 AM by Aoki² »

%slot here isn't the slot of the item in the GUI, it's the slot the image is mounted in on the player, 0 to 3. In general, items are mounted in slot 0.

You don't need to do %obj.tool[%slot].image to get the image, it's just %this.


I recommend that you just copy the ammo from the image without iron sights and put it on the iron sights one when you go into it, and copy it back when you're done.

Actually, now I look at it again, that seems to be what you're trying to do...

So then it'd be %obj.clipAmmo[%this.Image];?

So then it'd be %obj.clipAmmo[%this.Image];?
I'm now fully conscious and seeing that that doesn't make any sense at all.
Any more direct help, folks? To be honest, this issue is basically all that's keeping me from releasing my weapons as full add-ons.

Code: [Select]
function R101CADSImage::onMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%obj.currTool].Image];
   Parent::onMount(%this,%obj,%slot);
   %obj.pushDatablock(SlowArmor.getID());
   %obj.clipAmmo[%this] = %newAmmo;
}

function R101CADSImage::onUnMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%obj.currTool].Image];
   Parent::onUnMount(%this,%obj,%slot);
   %obj.popDatablock(SlowArmor.getID());
   %obj.clipAmmo[%this] = %newAmmo;
}
« Last Edit: September 01, 2014, 11:35:09 AM by Aoki² »

« Last Edit: September 01, 2014, 11:34:29 AM by Aoki² »

function R101CADSImage::onMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%obj.currTool].Image];
   Parent::onMount(%this,%obj,%slot);
   %obj.pushDatablock(SlowArmor.getID());
   %obj.clipAmmo[%this] = %newAmmo;
}

function R101CADSImage::onUnMount(%this,%obj,%slot)
{
   %newAmmo = %obj.clipAmmo[%obj.tool[%obj.currTool].Image];
   Parent::onUnMount(%this,%obj,%slot);
   %obj.popDatablock(SlowArmor.getID());
   %obj.clipAmmo[%this] = %newAmmo;
}

will give this a shot shortly


Bump, because i also would like to know this...