script only works for one side[solved]

W

Wild_West

Guest
I made an easy script for my chess game, that lets the pieces equip the weapons they can use for attacking the enemy side.
It works fine just for some reason not on the back pieces, only white.
The script doesn't name either side specifically, and both the white and black piece parent objects are using the script exactly the same way. If there's a deviation I can't see it.

The image illustrates what I mean :

The glowing symbol just shows that it's waiting to be equipped, and the one under the knight piece is equipped, and will move everywhere the knight does until it's either destroyed or lost from an in-game effect.
As I said I can't replicate this with the black pieces.

The weapon symbols are equipped after selection by pressing right on the mouse.

In the right mouse button for the black game piece parent

Code:
///equip weapon

switch(object_index)
{
   case black_bishop_obj : equip(axe_weapon_obj,   black_bishop_obj);
                           equip(spear_weapon_obj, black_bishop_obj);
                           equip(wand_weapon_obj,  black_bishop_obj);
   break;
   
   case black_queen_obj : equip(axe_weapon_obj,   black_queen_obj);
                          equip(spear_weapon_obj, black_queen_obj);
                          equip(wand_weapon_obj,  black_queen_obj);
   break;
}

This isn't really important it just tells the weapon to move to the selected piece's X and Y to trigge the equipping script.

Code:
///equip(weapon, piece);

]if(argument0.image_speed > 0)
{
    with(argument1)
    {
        argument0.x = argument1.x;
        argument0.y = argument1.y;
    }
}



The script to equip the weapon

Code:
///equip_to(piece);

if( place_meeting(x,y,argument0))
{  
   image_speed = 0;
   image_index = 0;
   
   target = argument0;
   
   target.is_equipped = true;
   target.equipment = name;
   target.IN_plv = plv_bonus;
}

//stay at x and y start if no piece has been selected yet
if(target != noone)
{
   x = target.x;
   y = target.y;
}
 

TheouAegis

Member
Code:
with(argument1)
   {
        argument0.x = argument1.x;
        argument0.y = argument1.y;
    }
There's no point using with() here. If you need to use with(), then don't use argument1.x and argument1.y - you either use with() and direct referencing or you use indirect referencing.
 
W

Wild_West

Guest
Code:
with(argument1)
   {
        argument0.x = argument1.x;
        argument0.y = argument1.y;
    }
There's no point using with() here. If you need to use with(), then don't use argument1.x and argument1.y - you either use with() and direct referencing or you use indirect referencing.
Mistake of getting a cluttered thought process yeah :p But it doesn't help my problem
 
W

Wild_West

Guest
You said white pieces' code works, so post that too.
It's exactly the same code as the black pieces that's why I didn't post it and why I couldn't find the problem.
I only separated the parent object and it's children for each one.
 

TheouAegis

Member
If you made some changes, then it is not exactly the same. Now, either you made a mistake in your code somewhere when copying it between parents, or you did not set your parents correctly. Or maybe you have some leftover code and your black pieces that is overriding the parents code.

Or maybe the issue is and how you are calling the equip_to() script, since I don't see any calls in your code for that. I would put a debugger breakpoint or a show message in that script to verify that it is actually running or not running. If you reach the break point, then the issue is not those codes that you posted but how the target is being passed between scripts. If you don't reach the break point, then the issue is how you call that script.
 
W

Wild_West

Guest
My debugger doesn't work.
But I went over both parents 6 times and compared everything trying to solve it.
equip_to is called in the weapon symbol object as the way to attach a weapon to a piece.
But I'll go over them again and see if I missed something you mentioned.
 
W

Wild_West

Guest
Okay it WAS the parents after all, I was sue I set the right one but I replaced the child objects a little after that and forgot to set the parent back to the black piece one.
The parent names for white and black are the same except fr the end which I couldn't even see in the box for setting them :p I'll change those names to prefixes so I can see them without having to remember to check them in the obj properties everytime.
Thanks for the help.
 
Top