Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Attach thing to player
Attach thing to player
2001-12-08, 4:11 PM #1
I'm trying to make a projectile cog so that when you press space on it, it gets attached to the player. This is what I tried:
Code:
symbols

message activated
int holding=0

end

code

activated:

player = GetLocalPlayerThing();

if(holding==1);
{
DetachThing(GetSenderRef());
holding = 0;
}

else
{
AttachThingToThingEx(GetSenderRef(), player, 0x8);
holding = 1;
}

return;

end

but nothing happens when I press it. Its based on a walkstruct, so would that be the problem?
2001-12-08, 8:38 PM #2
AFAIK walkstruct's cant be manipulated by cog commands besides the ones used in level doors and elevators. so yes that is the problem, make it a child of something else and it should work

p.s. if your reading this triz, you rule!

[This message has been edited by Maggot (edited December 08, 2001).]
2001-12-09, 5:01 AM #3
I tried making it a thing in a level, and linking the cog to it. But when I press it, nothing happens, it doesnt even print anything. The thing is a throwcrate, not based on a walkstruct.
Code:
symbols

thing   	item			desc=console
int 		holding=0		local
int         player                           local
message 	activated

end

code

activated:

player = GetSourceRef();
item = GetSenderRef();

Print("pressed");

if(holding==1);
{
DetachThing(item);
Print("detach");
holding = 0;
}

else
{
AttachThingToThingEx(item, player, 0x8);
Print("attach");
holding = 1;
}

return;

end

Anyone know why it doesn't work??

[This message has been edited by IDJunkguy (edited December 09, 2001).]

[This message has been edited by IDJunkguy (edited December 09, 2001).]
2001-12-09, 7:46 AM #4
I changed it to this:
Code:
symbols

thing   	item			linkid=0
int 		holding=0		local
int         player                           local
message 	activated
message	startup

end

code

activated:

player = GetSourceRef();
Print("pressed");

if(holding==0)
{
AttachThingToThingEx(item, player, 0x8);
Print("attach");
holding = 1;
}
else
{
ClearThingAttachFlags(item, 0x8);
DetachThing(item);
Print("detach");
holding = 0;
}

return;

end

I can hold the thing but it doesn't detach when I press it.
2001-12-09, 9:37 AM #5
Code:
symbols
thing   item linkid=0
int holding=0 local
int         player                           local
message activated
message startup
end
code
activated:
player = GetSourceRef();
Print("pressed");
if(holding == 0)
{
AttachThingToThingEx(item, player, 0x8);
Print("attach");
holding = 1;
}
else
if( holding == 1 )
{
ClearThingAttachFlags(item, 0x8);
DetachThing(item);
Print("detach");
holding = 0;
}
return;
end


Remember if(holding == 1), if it's missing it may cause some crap in your cog...

------------------
Punainen tiili kädes, sinä vapauteesi juokse.
Välil maan ja taivaan raha menee rahan luokse.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.

Punainen Tiili kädes, huomenna kaikki muuttuu.
Raha enää vain muisto, rakkaus enää vain puuttuu.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.

[This message has been edited by Cave_Demon (edited December 09, 2001).]
WHAT?

↑ Up to the top!