Jump to content

Hud melee script not working correctly.


TheGovnor
 Share

You are about to reply to a thread that has been inactive for 2898 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi I feel like a dosh.  Im new to scripting...

I have made a hud and scripted it to act like an on off button.  It works fine.

I have a melee script that i took from a weapon and then added the hud script to it, it saved without issue.

I have then put the melee+hud script into the object (hud) and added the animations etc.

The problem is when I touch the hud and it turns on, the melee part of the script wont activate.  The on state triggers the Draw msg..but for some reason the rest of the script isnt hearing the msg.

If I wear the weapon with the origonal melee script in it and then press the hud on screen the melee weapon activates o.O.  If I take off the weapon and wear just the hud with melee/hud script joined..the hud will trigger the melee part of the script if I type /65 draw in chat and all works fine o.O.

So communication is happening...just not within the joined melee/hud script itself.

I have looked and looked and tried alsorts of things but the press on wont activate the melee script when the two are as one script -_-.

I dont know what Im doing wrong, but feel its something to do with the melee script coming from an wear on avatar and the hud script isattachment to screen.  So they are not communicating as one, but will when seperate.  its doing my head in cos it probably very simple to fix grrr.

Hope this isnt to confusing..please help.

Link to comment
Share on other sites

Ok here are parts of the script.

 

string ownerName;

integer switch;
integer COM_CHANNEL = -12345;
integer status;

string draw_command = "draw";
string sheath_command = "sheath";

ButtonPress()
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, <0.01, 0.0775, 0.0775>]);

llTriggerSound("e6b5e02f-5d8a-831b-a951-0481981740b4",1);

llSleep(0.025);


llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, <0.01, 0.1000, 0.1000>]);


}

default
{
on_rez(integer params)
{
llStopSound();
llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
llSetLinkAlpha(1,0.0,ALL_SIDES);
ownerName = llKey2Name(llGetOwner());

}
state_entry()
{

llListen(COM_CHANNEL,"", NULL_KEY,"");

integer perm = llGetPermissions();
if (perm != (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION))

}

touch_start(integer total_number)
{
ButtonPress();

if (switch==0)
{
switch=1;
llSay(COM_CHANNEL,"draw");
}
else if (switch==1)
{
switch=0;
llSay(COM_CHANNEL,"sheath");
}
}

attach(key on)
{
if (on != NULL_KEY)
{

integer perm = llGetPermissions();

}

}

listen( integer channel, string name, key id, string message )
{
if(llGetOwner() != llGetOwnerKey(id)) return;

if(message == draw_command)
{
weapon_show();

}
if(message == sheath_command)
{
weapon_hide();

}
}

 

:)

Link to comment
Share on other sites

 What I was trying to do is put the on off  script inside the melee script and activate the melee script via the on off one within the melee script.    Hud will have to be 2 linked prims for it too work then, makes sense now....how did I miss that part :(.

Link to comment
Share on other sites

seems what you have is 3 attachments. A HUD (button), a sheathed weapon and a weapon in hand. The sheathed and hand weapon show/hide (with appropriate animation) when the commands "draw" and "sheath" are typed on channel 65

and what you want to do is click the HUD button to issue the commands, and not have to type the commands in chat ?!

if so then in the weapon(s) script(s) change the channel they listen on from 65 to the same as COM_CHANNEL in the HUD script

a normalised HUD (button) script (which you kinda basically have done already) is something like:

 

integer COM_CHANNEL = -12345;integer switch;default {   touch_start(integer total_number)   {      string cmd;      if (switch)      {          cmd = "draw";      }      else      { 	 cmd = "sheath";      };             llSay(COM_CHANNEL, cmd);  // tell the weapons script(s) what to do      llOwnerSay(cmd);          // tell the owner the last command            switch = !switch;         // flip the switch   }}

 

and other than changing the channel no. in the weapons script(s) you shouldn't have to do anything else to them, for them to work out-the-box

Link to comment
Share on other sites

Or you could do more extensive surgery to the scripts so that, instead of chat/listen, the internal communications are by linked message, which not only works within an object but also within a script (although, if these scripts are actually combined, there may be more efficient ways to integrate their logic, but at the price of understanding more of their internals).

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2898 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...