Jump to content

simulate a key press


Lolita Erin
 Share

Recommended Posts

hello i hope somebody can help me, i cant find how to do it if is posible,

i have on my script a control event, where i change the vehicle speed. all the code is there and work fine, is there a way i can send a code from a linked prim, that emulate for example the pgup key ? i this way the control event use necesary code to work on the vehicle?

 

thanks

Link to comment
Share on other sites

I'm not quite sure I understand what you're trying.  How were you planning to trigger the speed change from the linked prim?  Can't you just use the PgUP or PgDn keys to change speed?

control (key id, integer level, integer edge){    if (level & edge & CONTROL_UP)    {        Speed *=1.5;    }    if ( level & edge & CONTROL_DOWN)    {        Speed /= 1.5;    }}

 

 

Link to comment
Share on other sites

Ah, I see.  I was assuming that you will be in mouselook while you are controlling your object.  If so, you can't click on a prim to trigger a dialog.  That was my source of confusion.  If you're not going to be in mouselook, that's not an issue.  Therefore, you don't need to simulate the PgUp key at all.

touch_start(integer num){    llDialog(llDetectedKey(0), "Increase or decrease speed.",["Faster", "Slower"],gChan); }listen (integer channel, string name, key id, string msg){    if (msg == "Faster")    {        Speed *= 1.5;    }    else if (msg == "Slower")    {        Speed /= 1.5;    }    llDialog(llGetOwnerKey(id), "Increase or decrease speed.",["Faster", Slower],gChan);  //Show dialog again}

 

Link to comment
Share on other sites

Thanks so much for you help, but i not explaining my self ( my english is not very good lol)

 

in my code i have 

control event i have many code for the key is press, like sounds, thtrotle number, hud info, etc. i dont like to duplicate that code in a listen event or other event, that is why i like to send some code like: "control ( CONTROL_UP )" to be able to use all my code in the control event

i hope i explain my self 

and thank you so much for you time

Link to comment
Share on other sites

you cant directly simulate a keypress in LSL like you can in other languages, so that it fires as a event

+

one way you can do what you want is to put everything currently in the control event in a seperate own function. Example:

 

myowncontrol(integer level, integer edge){   // ... copypasta all from control event}default(){  control(key id, integer level, integer edge)  {       myowncontrol(level, edge);  }}

 

+

now can pass key controls constants to myowncontrol(level, edge) from other parts of your script and/or scripts. dialog or linkmessage or listen as you like

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...