Author Topic: Image slot 1 not properly handling setImageTrigger  (Read 1717 times)

Hello fellow coders (and hopefully Badspot or anyone else with the power to tell me what the hell the engine is doing here)!
As some of you might know, i am working on a dual wielding script.
In case you did not know this, you do now.

But i seem to have some issues with the engine which can be solved but are just plain silly.
The issue is that if you use setImageTrigger to set the trigger of an image in mount slot 1 to true, it will cause something similar to setting the trigger to 1 and immediatly to 0.
Example:
I have equipped the sword in mount slot 1 by some means and redirect my jet key to set the imageTrigger accordingly to the input of the jet trigger.
So in theory, by holding my jet key, it should swing constantly.
In theory, this should be the same as having the sword equipped like normal and holding the fire key.

However, the sword does 1 swing and then stops.
However, after placing some echo's to see if the trigger gets set to 0 before i let go of my jet key, i do not see anything strange, it sets the trigger when i want it.
In fact, after some looking around, i found that Badspot even uses this mechanic in the Akimbo Gun code.
As he sets the trigger for the left handed gun to shoot, but never resets it to 0, which is odd, because in working theory it should then never be able to shoot after that initial shot.

To make things worse, as far as i can see, mount slot 1 is the only slot with such behavior.
I can and probably will use mount slot 2 without this problem, but it is just very weird and unnecessary behavior of this mount slot and it's image.

Can this be fixed by either a script i can write or can this be patched in an update?
I know it is minor, but things like this are a slap in the face of logics when trying to find out what is going on.

EDIT:
I have attached the script as is for reference.
When you have executed the code, just load as normal, open item inventory when you have spawned, right click to equip an item in mount slot 1, close item inventory, use Jet key to fire from mount slot 1.

Most relevant piece:
Code: [Select]
function Armor::onTrigger (%data, %player, %slot, %io)
{
%noParent = 0;
if (%player.isEquipping)
{
%noParent = 1;
if (%io)
{
if (%slot == 4) //JET
{
%player.mountImage(%player.equipImage, 1);
%player.client.bottomPrint("You equipped the item to your Jet key.",100,1);
}
else if (%slot == 0 || %slot == 1) //FIRE
{
%player.mountImage(%player.equipImage, 0);
%player.client.bottomPrint("You equipped the item to your Fire key.",100,1);
}
}
}
else if (%slot == 0 || %slot == 1)
{
%noParent = %data.redirectTrigger(%player, 0, %io);
}
else if (%slot == 4)
{
%noParent = %data.redirectTrigger(%player, 1, %io);
if (%player.getMountedImage(1) != 0)
{
%noParent = 1;
%player.setImageTrigger(1, %io);
}
}

if (!%noParent)
Parent::onTrigger(%data, %player, %slot, %io);
}

//TRACKING
function ShapeBase::setImageTrigger(%player, %slot, %io)
{
echo("SET IMAGE TRIGGER DOING: PLAYER" SPC %player SPC "| SLOT" SPC %slot SPC "| IO" SPC %io);
Parent::setImageTrigger(%player, %slot, %io);
}
Yes this is packaged properly. :)
And do not mind the redirectTrigger, that is a function that always returns 0 for now.
I might have written a lot of code before i checked if every step before that worked.
I was not counting on this silly engine quirk.
« Last Edit: April 11, 2016, 02:00:22 PM by lordician »

If I remember you actually can't force triggers on Players, it'll go back to what the player was doing

If I remember you actually can't force triggers on Players, it'll go back to what the player was doing
I am forcing the trigger on images mounted to the player.
And this actually works.
For example, i changed slot 1 to slot 2 and it worked properly.
Same goes for all other slots, except 1...

But i did notice what you said in some other work.
I actually found this out with crouching and like playertypes you mount to (mechs).
Turns out if you force the crouch trigger on your mounts, they will not actually do that action until after you dismounted, another silly quirk....

Tested, happens with 0 and 1, but not 2 and 3.

you can try using a hacky method instead like setImageAmmo or setImageLoaded to trigger the swinging

you can try using a hacky method instead like setImageAmmo or setImageLoaded to trigger the swinging
I am just trying to figure out why mount slot 1 specifically is faulty like this.
I already can easily use mount slot 2 to make it work fine, that is the stupid thing.
But thanks. :)

you can try using a hacky method instead like setImageAmmo or setImageLoaded to trigger the swinging
The problem with this is that he wants to make a dual wielding system. Doing stuff like that would require making a duplicate image for every weapon and detecting how to get it to fire with those functions, based on how the weapon already functions.

I am just trying to figure out why mount slot 1 specifically is faulty like this.
I already can easily use mount slot 2 to make it work fine, that is the stupid thing.
But thanks. :)
I think hats use slot 2 and emotes use slot 3. So either way, it's going to be incompatible with something.
« Last Edit: April 11, 2016, 03:36:50 PM by Shift Kitty »

The problem with this is that he wants to make a dual wielding system. Doing stuff like that would require making a duplicate image for every weapon and detecting how to get it to fire with those functions, based on how the weapon already functions.
I think hats use slot 2 and emotes use slot 3. So either way, it's going to be incompatible with something.
There are a max of 8 slots to choose from, i can make it compatible. :)
I could even detect for free slots if i really want to make it 100% compatible.

I wish we could have more slots

There are a max of 8 slots to choose from, i can make it compatible. :)
Not exactly.
There are 8 mountpoints, yes. Where an image is mounted to depends on the datablock's mountpoint value.
When it comes to actually mounting them, there's only 4 slots. The slot it's mounted to does not affect where it visually shows up. Just which trigger activates it.
The difference between the two is that there's 8 mountpoints, and 4 image slots. Image slots are function, mountpoints are form. You can even have multiple images on the same mountpoint.

Now, a solution to your problem. Since you plan on using an invisible tiny player in the left hand anyway, there's actually no need to fuss with which slot it's in anyway. The invisible left hand player isn't going to be emoting or equipping hats. Mounting players uses separate slots from mounted images.

Not exactly.
There are 8 mountpoints, yes. Where an image is mounted to depends on the datablock's mountpoint value.
When it comes to actually mounting them, there's only 4 slots. The slot it's mounted to does not affect where it visually shows up. Just which trigger activates it.
The difference between the two is that there's 8 mountpoints, and 4 image slots. Image slots are function, mountpoints are form. You can even have multiple images on the same mountpoint.

Now, a solution to your problem. Since you plan on using an invisible tiny player in the left hand anyway, there's actually no need to fuss with which slot it's in anyway. The invisible left hand player isn't going to be emoting or equipping hats. Mounting players uses separate slots from mounted images.
I actually thought there were 8 slots for images due to this in the Quick Reference Manual for Torquescript:
Quote
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only
has eight mount slots. Mount nodes are points on the mesh used by the shape while slots
are used to track how many objects and images are mounted to a shape.
But after some testing i actually noticed i could only get to mount to 0 to 2. (Actually 3, might have done something wrong tho...)
I guess the other slots are reserved for objects or something.
Can't seem to find information about that.

As for your solution, i know.
The problem at hand is just something i found while doing some early tests.
Though for some weapons that will be fully supported to this i want to give the developers the ability to give a special left handed image (for when you have a dualhanded item or just one that needs to be mirrored to look good/have the shell ejecting make more sense).
So i will equip those images that have mountPoint = 1 to slot 1, which still has the problem of the trigger going in the up while it is down for no logical reason.
Which is limiting more than it is useful...
I could still just tell people to make those lefthanded images mount to node 0 and still mount it to the hand bot, but it is just silly that this basically requires such a way around in that situation.