Nemopai Posted March 1, 2023 Share Posted March 1, 2023 The bottom of the script (i highlighted in orange for reference) keeps giving me a syntax error. I am fairly new to scripting and I've search for 2 days now and I just can't seem to find or see what I am doing wrong here? Any help would be appreciated and if I'm posting this in the wrong place I apologize integer FLOAT_HEIGHT = 5; // change this value to adjust the height of the floating object float swaySpeed = 0.1; // change this value to adjust the speed of the sway motion float swayAmplitude = 1.0; // change this value to adjust the amplitude of the sway motion integer listener; // the ID of the chat listener vector startPos; // the starting position of the avatar rotation startRot; // the starting rotation of the avatar integer TOUCH_CHANNEL = -422; // change this value to adjust the channel that the object listens on for touch events default { state_entry() { startPos = llGetPos(); // store the starting position of the avatar startRot = llGetRot(); // store the starting rotation of the avatar llSetTouchText("Touch to attach to right hand"); // set the touch text of the object llListen(TOUCH_CHANNEL, "", NULL_KEY, ""); // listen for touch events on the specified channel } touch_start(integer total_number) { key toucher = llDetectedKey(0); // get the key of the avatar who touched the object llRequestPermissions(toucher, PERMISSION_ATTACH); // request permission to attach the object to the avatar's hand } run_time_permissions(integer perm) { if (perm & PERMISSION_ATTACH) // if permission to attach was granted { key toucher = llDetectedKey(0); // get the key of the avatar who touched the object llAttachToAvatar(toucher, ATTACH_RHAND); // attach the object to the avatar's right hand llOwnerSay("Attached to your right hand."); // send a message to the owner of the object listener = llListen(0, "", toucher, ""); // listen for chat prompts from the avatar who touched the object llSetTouchText(""); // clear the touch text of the object } } listen(integer channel, string name, key id, string message) { if (message == "drink") // if the message is "drink", start the floating motion { llSetAnimationOverride("drink"); // animate the avatar to make a drinking motion llSetTimerEvent(1.5); // set a timer to start the floating motion after a delay } else if (message == "burp") // if the message is "burp", stop the floating script and reset the avatar to its starting position { llListenRemove(listener); // remove the chat listener to stop listening for prompts llSetPos(startPos); // set the avatar's position to its starting position llStopAnimationOverride("drink"); // stop the drinking animation llStopSound(); // stop any sounds that may be playing llSetRot(startRot); // set the avatar's rotation to its starting rotation } } timer() { vector pos = llGetPos(); // get the current position of the avatar pos.z += FLOAT_HEIGHT * llGetTime(); // calculate the new position of the avatar based on the FLOAT_HEIGHT and the elapsed time float swayAngle = llSin(llGetTime() * swaySpeed) * swayAmplitude; vector swayAxis = <1.0, 0.0, 0.0>; rotation swayRotation = llEuler2Rot(<swayAngle, 0.0, 0.0>); llSetLocalRot(swayRotation * startRot); // apply the sway motion to the avatar's rotation llSetPrimitiveParams([PRIM_POSITION, pos]); // set the new position of the avatar llSetTimerEvent(0.1); // set a timer to update the position of the avatar // animate the avatar with a swaying motion list animList = ["HEAD", "LARM", "LFOREARM", "LHAND", "LLeg", "LFoot", "RARM", "RFOREARM", "RHAND", "RLeg", "RFoot"]; float t = llGetTime() * swaySpeed; float amp = llSin(t) * swayAmplitude; vector axis = <1.0, 0.0, 0.0>; rotation rot = llEuler2Rot(<amp, 0.0, 0.0>); foreach (string name in animList) { llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_ROTATION, rot * llList2Rot(llGetAnimationOverride(name))], llGetLinkNumber(name)); } } Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 1, 2023 Share Posted March 1, 2023 (edited) There is no "foreach", "for each", etc. in LSL. https://wiki.secondlife.com/wiki/For integer iListLength; integer iListPos; iListLength = llGetListLength(mylist); for (iListPos = 0; iListPos < iListLength; ++iListPos) { string sOneEntry; sOneEntry = llList2String(mylist, iListPos); // do stuff with sOneEntry here } // end of for() loop Edited March 1, 2023 by Love Zhaoying Link to comment Share on other sites More sharing options...
Anna Salyx Posted March 2, 2023 Share Posted March 2, 2023 (edited) Also, you cannot called "llDetectedKey()" inside of the run_time_permissions event. it'll fail without an error. It can only be called from inside detection events (collision, collision_start, collision_end, sensor, touch, touch_start, touch_end) or in functions called by detection events. Also also a "TOUCH_CHANNEL" variable is being declared and assigned to a listener to ostensibly handle touch events, but touch events do not require a listener to function. No event does. The TOUCH_CHANNEL Is being used in no other place and is not even being handled by the listen event. There are a few/several other "also"s that I won't take time pointing out. This has the feel of an AI generate script that is kinda there but not quite. Edited March 2, 2023 by Anna Salyx 3 1 Link to comment Share on other sites More sharing options...
primerib1 Posted March 3, 2023 Share Posted March 3, 2023 On 3/2/2023 at 12:19 PM, Anna Salyx said: This has the feel of an AI generate script that is kinda there but not quite. Indeed! No AI transform engine currently is able to write a complex-ish LSL script. Better to just ask a scripter to write one if it's complex. ChatGPT is known to make up fictitious event handlers, and even misunderstand completely what some llFunctions do... (Well, ChatGPT doesn't actually understand what it's writing. It only knows that what it writes "looks good according to its AI algorithm", but it has no domain knowledge, like, at all.) Other Transform engines are likely doing the same: Generating something that "feels right" but isn't. 2 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