RilaVirum Posted February 4, 2021 Share Posted February 4, 2021 Need help please. How can I jump from Event to Event? I have two events and I'm trying to go from a listen event to a dataserver event but I keep getting "Syntax Error" on dataserver default { state_entry() { Listen_Detect = llListen(0, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { key Owner = llGetOwner(); key OwnerID = llGetOwnerKey(id); if(OwnerID != Owner) return; else { llGetOwner(); llListenRemove(Listen_Detect); } dataserver(key ListA, string lsData) { //No more lines to read if(lsData == EOF) { llSetText("End of notecard reached", <1,1,1>, 1); llSleep(1.0); llSetText("", <1,1,1>, 1); } Link to comment Share on other sites More sharing options...
KT Kingsley Posted February 4, 2021 Share Posted February 4, 2021 (edited) You've left out some braces (curly brackets): integer Listen_Detect; default { state_entry() { Listen_Detect = llListen(0, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { key Owner = llGetOwner(); key OwnerID = llGetOwnerKey(id); if(OwnerID != Owner) return; else { llGetOwner(); llListenRemove(Listen_Detect); } }//missing dataserver(key ListA, string lsData) { //No more lines to read if(lsData == EOF) { llSetText("End of notecard reached", <1,1,1>, 1); llSleep(1.0); llSetText("", <1,1,1>, 1); } }//missing }//missing Keeping your braces aligned really helps sort out that kind of issue. Incidentally, all that testing for the owner in the listen event is redundant: you've specified the owner in the call to llListen, so only chat from the owner will ever trigger the listen event. Also, for this to compile you need to define Listen_Detect as a global integer, before the default state, as in the code I've shown above. Edited February 4, 2021 by KT Kingsley 1 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 4, 2021 Share Posted February 4, 2021 (edited) I don't quite see what you are trying to do here, so it's hard to know how to help. Perhaps it would be a good idea to step back a bit and review the structure of LSL, which is not like other computer languages you may have learned. LSL is based on states and events, both of which are blocks of logical instructions. States are possibly easier to understand, because they are like self-contained programs. Many (most?) LSL scripts, in fact, only have one state, named default. If a script has other states, they can be thought of as semi-independent bodies of instructions, capable of standing on their own but tied together loosely to make a larger script. Events, on the other hand, cannot stand alone. They are coherent logical blocks, each with a specific purpose -- responding collisions, messages, or the passage of time, for instance. Execution of an event is triggered by an action, and cannot leave the event until the work defined in the event has finished. Unlike most other languages you may have encountered, execution in a LSL script does not proceed in a linear fashion. It does not start with the first line of code in the script and continue straight through to the end. Instead, a script, once started, simply waits for something to trigger one of its events. If nothing triggers it, the script will just sit there forever. When something does trigger it, execution proceeds directly to the event that was alert for that trigger. The event does its work and then waits... until some other action takes place, triggering that event again or a different event. And so it goes, continually, execution hopping from one event to another as the outside environment triggers it and waiting if nothing happens at all. So.... you have a listen event that is waiting for a message from God knows there, but so far you have not told it what to do when a message triggers it. You have simply told it to stop doing anything if the owner's ID isn't the owner's ID (which is not likely), or to stop listening. So the listen event will be triggered by one message on the PUBLIC_CHANNEL (channel 0), and then will never do anything again. You also have a dataserver event, which needs to be triggered by a command to look for data in some storage medium. In this case, you want it to look in a notecard. Unfortunately, you have not included a trigger -- an instruction that uses llGetNotecardLine() to tell the dataserver event how to start. No trigger, no way to get into the dataserver event. The event itself also has only one task so far. If the line it reads is the last line on the card, it will put a message in hover text to let you know. That's it. So, it seems that what you may want to do is put that llGetNotecardLine trigger in the listen event, to be executed when the listen event is triggered by some important message. When that happens, execution will leave the listen event and hop to the dataserver event to read a line in the notecard. If you want it to do more than that, you'll have to provide other triggers. I suggest going back and working through some basic LSL tutorials at http://wiki.secondlife.com/wiki/Category:LSL_Tutorials to get a better feel for what I have tried to explain. You will find a specific tutorial on reading a notecard, but don't look at it until you have done the foundational tutorials first. It's not a simple one to jump into. I also suggest visiting Builder's Brewery in world to look for a free LSL class. Then start looking for very simple scripts that you can tinker with, exploring how they work and what you can redesign them to do. Edited February 4, 2021 by Rolig Loon typos. as always. 1 1 Link to comment Share on other sites More sharing options...
RilaVirum Posted February 4, 2021 Author Share Posted February 4, 2021 Ok I will work with all the curly brackets! Thanks. Ok, That extra line is unnecessary? I had a feeling it was..lol. And yes that's what I'm trying to do, I'm trying get the chat from the owner only. I'm using the listen to secure my sound object. When you click on the box it makes a sound, I'm trying to get the sound to only respond to it's owner. It's for a class lol. Link to comment Share on other sites More sharing options...
KT Kingsley Posted February 4, 2021 Share Posted February 4, 2021 (edited) To respond to clicks, you need a touch_start event. In that event you can test the result of llDetectedKey(0) to see if it's the owner. touch_start (integer count) { if (llDetectedKey (0) == llGetOwner ()) { //Clicked by the owner llPlaySound ("My sound clip", 1.0); } else { //Clicked by someone else } } If all your script is intended to do is to make a noise when the owner clicks it you only need the touch_start event. I'm guessing, though, that the script is actually doing other things that do require listening to chat and reading notecards, beyond what you've posted. Edited February 4, 2021 by KT Kingsley Oops - missing parenthesis (round bracket) 1 Link to comment Share on other sites More sharing options...
RilaVirum Posted February 4, 2021 Author Share Posted February 4, 2021 Oh wow ok I see, that's different. Yeah I started coding in Java, that was my first coding language, I was hoping the Event would respond straight down the script, but I see that's not how it works, in a Linear fashion like you're saying Rolig. The dataserver is for the Notecard, it's separate from the listen. I kept getting a syntax error on the dataserver event, but I don't get why. On the listen, I'm trying to get it to get the Key Owner, So that the objects scripts only respond to the owner. And ok, I will take notes on what you said! I'm still trying to get the LSL Script Structure down thank you Rolig. Link to comment Share on other sites More sharing options...
RilaVirum Posted February 4, 2021 Author Share Posted February 4, 2021 Yes it's a Cube that plays a sound, and yes! it has a lot of more code in it lol. Ok I will try that Function, Thank You! Link to comment Share on other sites More sharing options...
Recommended Posts
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