GANI Light-Saber Fix?

So, I’m currently trying to build my first custom weapon. I’ve scoured the forum for examples, which has helped alot. Other examples, that were mentioned often, but only lead to 404 errors/no longer accessable links such as for a Zodiac Weapon tutorial frequently mentioned…

Here is my current script:

if (playertouchsme) {
  toweapons Weapons/MC-LightSaber;
  set Weapons/MC-LightSaber;
  if(this.on == 1){
    setplayerprop #P2,Lightsaber_MultiColor.gif;
    replaceani idle,Lightsaber_MultiColor_Idle;
    replaceani sword,Lightsaber_MultiColor_Attack;
    replaceani walk,Lightsaber_MultiColor_Walk;
    setplayerprop #P2,sword1.png;
    replaceani Lightsaber_MultiColor_Idle,Lightsaber_MultiColor_Idle;
    replaceani Lightsaber_MultiColor_Attack,sword;
    replaceani Lightsaber_MultiColor_Walk,walk;

Here’s the test result:

Player starts. (weaponIDLE animation already shows)
Player walks to weapon NPC to touch & obtain weapon. (weaponWALK animation keeps running even after releasing direction keys.)
Player obtains weapons, presses D to unsheathe the weapon. (No unsheathing animation yet, will create after the rest of the script is fixed.)
Player presses S to attack. (weaponATTACK animation works, then returns to regular IDLE animation instead of weaponIDLE.)
Player walks in any given direction, after the direction key is released the weaponWALK animation continues.

I guess what I’m trying to fix is a key release trigger(?) to change the weaponWALK animation to weaponIDLE upon said key release(directional keys).
I believe the key release trigger should go inside “if(this.on=(this.on+1)%2;” underneath the replaceani commands, but this is where I’m getting myself confused.
I may just have a few wires crossed in the conditional branch also, which is why I’m asking for some corrections with the logic.

I’m trying to figure out how to perform a keyrelease command: if (keyreleased) (?)
I can’t seem to locate it in the commands.rtf. I’ve found the keypressed flag, but no keyrelease type flag. Any ideas?

*I understand that this base question has been asked alot on here, but the references I’ve tried to locate again, seem to no longer exist.

Your script logic for the most part seems fine. Just the part where you sheath the weapon again seems inconsisent where you replace the idle gani back to to the original.
If you post the ganis I can take a quick look at them for errors.

As for why you revert from the attack animation back to the normal idle, look out for the SETBACKTO command in gani, this will cause the exact behaviour you’re experiencing. To fix it, simple replace “idle” in SETBACKTO with your weapon’s idle gani.

I’ve sent him your get_keys code… should help.

[USER=“10627”]2ndwolf[/USER] Thanks, I’ll look over it now

[USER=“5637”]tricxta[/USER] Here’s a .rar containing the gani’s, script, and images. Thanks for the tip, I went by a tutorial for working graal shop while making these ganis.

time to try this again, I’ll have an update in a few

I don’t typically do this, but I fixed everything up for you.

It seems as though the filenames were the culprits for the running bug (I didn’t really bother persuing the limits of this, but I don’t think graal likes mixed case, so keep your filenames all to lower case). And I also changed the attack gani to set back to the light saber idle gani.

I’ll remember to keep things lowercase from now on, just a habit I had to help certain names stick out in a group.
Your script 2ndwolf provided, helped break down how arrays can be used.

This has given me some new ideas I want to try making once I get this down packed.
learning how to script through gs has been a grind so far, but it’s getting better as I learn to do more complex things.

I don’t expect anyone to do it for me, I’d like to try and figure it out myself first. Now that I see how to use values
in an array I’ll be able to come up with some new ways of using conditions and variables.

A lightbulb finally clicked!

Awesome. I’m looking forward to seeing more competent scripters emerge and create content that’s fun to interact with.