-
Posts
38 -
Joined
-
Last visited
Content Type
Forums
Blogs
Knowledge Base
Posts posted by Emilee Edenflower
-
-
OK, hopefully someone can help me here as whatever I do always results in a 0 (zero) output!
I'm just trying to do a simple calculation to work out the percentage of memory. It really shouldn't be so difficult, should it?? I thought maybe there was limitation with how much maths could be done in one line, so I split the two calculations up and it still doesn't work as expected.
The calculation should look something like: 34968 / 65536 * 100 which rounded up should be about 53%. I wasn't sure if you could use parenthesis in it or not, but it didn't work anyway (eg: (34968 / 65536) * 100)
integer used_memory = llGetUsedMemory(); integer total_memory = llGetMemoryLimit(); float percentageMaths = used_memory / total_memory; float percentageMemory = percentageMaths * 100; llOwnerSay("Memory used as percentage: " + (string)llRound(percentageMemory)); //result as: "Memory used as percentage: 0"
Any insights?
-
1 hour ago, Rolig Loon said:
Nothing is "hit". There is no beam of particles or bullets. It's a simple query to the servers.
Hmm, that's a shame. It'd be handy to be able to grab the "collision". Oh well!
-
Cast ray is all very new to me so this may be a silly question, but is there a way to detect the "hit" from a cast ray weapon? The traditional collision detection obviously doesn't work, and from what I do understand (if I read it right) of cast ray, it operates on a channel number type of thing between the weapon and target to detect the hit?
So can you detect a "collision" if you don't know the original script of the weapon system for like a generic cast ray collision detection?
-
1 hour ago, Rolig Loon said:
If you have a list to send, you'll need to pack it into a string and then parse it back out to a new list at the receiving end
Thanks, this should hopefully accomplish what I'm aiming for Thanks for all the help!
-
OK, final question then to make my idea work if possible. I'd like to keep the scanner script separate just for tidiness (since I can't use an include() function) -- so can't lists be sent between scripts with a llMessageLinked ? I don't quite understand how that function works across scripts, and the examples on the docs don't really make it any clearer to me..
-
22 minutes ago, Rolig Loon said:
if ( llListFindList(TARGET_LIST,[(string)id]) >= 0 )
( or as if ( ~llListFindList(TARGET_LIST, [ (string)id ] ) )
Ah, of course. It seems so obvious now you've said it! Thanks!
-
I understand the need for typecasting at times, I'm just getting confused about how to do this within LSL, inside a loop whilst using llListFindList if the initial list I made isn't counted as a list of keys
Do I need to use llList2Key on my TARGET_LIST and SEEN_LIST somehow for the llListFindList to understand the comparison of keys? I think I've been staring at this for too long now
list TARGET_LIST = ["0f2e3a53-b856-413f-823b-71c10ca4aa58", "3a5add55-270d-4076-9e50-d4f37f2ad8af", "a6d06686-5198-4ff7-b42e-a7b4a75aaa5d", "d4b33149-686f-4bf4-b184-e8196a258b7a", "476c19b4-011e-4781-9e98-cefafe8f8606", "3498dd86-e37d-4f43-95c0-436121705a55", "3a5add55-270d-4076-9e50-d4f37f2ad8af"]; list SEEN_LIST; integer i = llGetListLength(SEEN_LIST); list REGION_KEYS = llGetAgentList(AGENT_LIST_REGION, []); integer NUM_KEYS = llGetListLength(REGION_KEYS); key id; while ((--i) >= 0) { id = llList2Key(SEEN_LIST, i); if (llListFindList(REGION_KEYS, [id]) < 0){ SEEN_LIST = llDeleteSubList(SEEN_LIST, i, i); } } // check for any on TARGET_LIST, when so add to SEEN_LIST while ((--NUM_KEYS) >= 0) { id = llList2Key(REGION_KEYS, NUM_KEYS); if (llListFindList((key)TARGET_LIST, [id]) >= 0) { if (llListFindList((key)SEEN_LIST, [id]) < 0) { SEEN_LIST += [id]; llOwnerSay(llGetDisplayName(id) + " is in your region of " + llGetRegionName() + "!"); } } }
-
On another note, do I need to do something to define my list as a list of keys? The while loop with the list to list thing doesn't seem to be seeing anything. Keeps returning -1 even though I have keys in my target_list the same as those avi in the region I'm in..
-
4 minutes ago, Rolig Loon said:
I think the real problem in your script is that llKey2Name is often turning up NULL_KEY answers when you don't expect them, so the variable this_agent_key is unreliable.
Yeah I've swapped it now to just be a list of UUIDs and I'll convert the key to username on output in llOwnerSay instead. Just about to try it inworld now
-
10 hours ago, Rolig Loon said:
Uh-oh. I stand corrected. I don't know what I was thinking when I typed that. You just startled me enough that I went back and checked that gate counter script that I pointed the OP to, just to be sure I didn't make the mistake there. I didn't. The script is right (Whew). I just had a brain failure here today. Thanks, Innula.
So in light of all that, and using lists instead of strings.. does this make sense for memory checking, or does it have to be a string?
if ((llGetListLength(TARGET_LIST) * 4.2) > llGetFreeMemory()) { //Delete the oldest entry in the list which is at the front of the list TARGET_LIST = llDeleteSubList(TARGET_LIST,0,0); }
-
2 hours ago, ellestones said:
the function should go something like:
list ListItemDelete(list source, string item) { integer i = llListFindList(source, [item]); if (i >= 0) return llDeleteSubList(source, i, i); else return source; }
It looks similar to what I've got, it's just the IF part that's a bit different, though it looks to be saying the same thing from what I can tell:
list ListItemDelete(list mylist,string element_old) { integer placeinlist = llListFindList(mylist, [element_old]); if (placeinlist != -1) return llDeleteSubList(mylist, placeinlist, placeinlist); return mylist; }
-
Thanks I'll check it out! I don't expect there'd be many more than 20 (at most!) in a list at any one time with what I'm planning, but you never know. Even if I don't hash my list, this part looks like it could be useful to utilise in a modified way maybe:
if ((llStringLength( hashedNames ) * 4.2) > llGetFreeMemory()) // In case memory gets tight { hashedNames = llGetSubString(hashedNames,3,-1); //Delete the oldest entry in hashedNames }
-
5 minutes ago, Rolig Loon said:
Scripts will survive region restarts, being taken to inventory and re-rezzed, being detachd and reattached, and a variety of other things, unless you have put explicit llResetScript statements in them.
Thanks, that's what I was hoping For this script, I'm mainly just thinking in terms of people storing a list of avatar keys/UUIDs now for the purpose of the snippets posted above in this thread. I have considered using the HTTP request functions to update and retrieve data stored on a server via PHP scripts instead to make sure things are more durable and/or persistent.
-
2 hours ago, Rolig Loon said:
You are using llKey2Name to get the names of agents who are no longer in the region. That will not work. llKey2Name will only work for agents currently in the region.
Ah, right thanks for the heads up. I was using names as it was a customisable list, but I suppose I could do it another way which I was considering which was to store UUIDs instead, but it just meant the list couldn't just be stored/edited in a note file as easily/human-readable. But that's fine
As for the list (however I create it now), if I store names in it as a variable -- will they be 'remembered' even after logging out if the script doesn't have any reset functions in it?
-
OK I thought it was working.. but it still spams the chat and the SEEN_LIST doesn't remove anyone if they leave the sim. hmmm..
Here's the code again, I tidied up a few things which were causing compiling errors
timer() { REGION_KEYS = llGetAgentList(AGENT_LIST_REGION, []); NUM_KEYS = llGetListLength(REGION_KEYS); if (NUM_KEYS == 0) { SEEN_LIST = []; return; } key id; //llOwnerSay(llDumpList2String(SEEN_LIST, ",")); // remove a previous seen target if no longer present on region integer i = llGetListLength(SEEN_LIST); string this_agent_name; string this_SEEN_name; while ((--i) >= 0) { id = llList2Key(SEEN_LIST, i); this_SEEN_name = llKey2Name(id); if (llListFindList(REGION_KEYS, [id]) < 0){ //SEEN_LIST = llDeleteSubList(SEEN_LIST, i, i); SEEN_LIST = ListItemDelete(SEEN_LIST, this_SEEN_name); } } // check for any on TARGET_LIST, when so add to SEEN_LIST while ((--NUM_KEYS) >= 0) { id = llList2Key(REGION_KEYS, NUM_KEYS); this_agent_name = llKey2Name(id); if (llListFindList(TARGET_LIST, [this_agent_name]) >= 0) { if (llListFindList(SEEN_LIST, [this_agent_name]) < 0) { SEEN_LIST += [this_agent_name]; llOwnerSay(llGetDisplayName(id) + " is in your region of " + llGetRegionName() + "!"); } } } }
-
58 minutes ago, ellestones said:
in this case then I probably maintain a list of targets currently on the region. A seen list and then do it in 2 passes. Something like
Thanks I'll give it a try later
-
Thanks for the replies. Haven't tried it yet but I thought I might just add (since I forgot to say in the OP): TARGET_LIST is a list of predefined avatar user names you want to look for. So it's trying to cross reference agents in the region with your custom list and notify you if they enter the sim and notify you only once they arrive unless they leave and come back later.
Not sure if this changes how you'd respond to my code or your examples?
-
OK so i'm probably overlooking something really simple in the logic, but I can't see it for myself right now.
I just want the llOwnerSay("so and so is in the region") to only display once if that avi has been detected already and added to the "seen" list (unless they are removed and come back later).
I'm sure it's something simple I'm overlooking, but any help would be nice! If there's a better way to do this, please suggest it also!
timer(){ //Recheck the region REGION_KEYS = llGetAgentList(AGENT_LIST_REGION, []); NUM_KEYS = llGetListLength(REGION_KEYS); key thisAvKey; string this_agent_name; integer i; for (i = 0; i < NUM_KEYS; ++i) { thisAvKey = llList2Key(REGION_KEYS,i); this_agent_name = llKey2Name(thisAvKey); //See if targets are in your region integer listIndex = llListFindList(TARGET_LIST, [this_agent_name]); //llOwnerSay((string)listIndex); if (listIndex != -1) { //Update notifation list SEEN_NOTI += [this_agent_name]; SEEN_NOTI = ListUnique(SEEN_NOTI); //llOwnerSay(llDumpList2String(SEEN_NOTI, ",")); if (llListFindList(SEEN_NOTI, [this_agent_name]) != -1){ //Only give notifation if it's not been said already! llOwnerSay(llGetDisplayName(thisAvKey) + " is in your region of " + llGetRegionName() + "!"); } //Remove from SEEN list if they leave the region if (llGetAgentSize(thisAvKey) == ZERO_VECTOR){ llOwnerSay("removed " + this_agent_name + "from the list!"); SEEN_NOTI = ListItemDelete(SEEN_NOTI, this_agent_name); } //llOwnerSay(llDumpList2String(SEEN_NOTI, ",")); } } }
-
1 minute ago, Rolig Loon said:
I am accustomed to splitting large scripts and using linked messages to pass data between them
I did look at linked messages, but the examples weren't very clear on how to pass data between things. Are there any better examples out there?
-
37 minutes ago, Wulfie Reanimator said:
TLDR: Even with includes, can't include scripts and there are a lot of problems for anyone but you viewing the script.
OK thanks. That kinda sucks though. Does LSL ever get an update ??
-
4 hours ago, ellestones said:
Firestorm viewer, or any other TPV that has imported the preprocessor
https://wiki.phoenixviewer.com/fs_preprocessor
So there's no built in function to just include another script from within the same object, without depending on a certain viewers preference setup? That seems a little clunky.
-
Hi, this may be a newb question, but I'm more familiar with PHP. Is there an LSL equivalent of an "include()" function so that an object can have a larger script split up into more manageable parts and included in the main script? I'm finding it rather cumbersome to have such loooong scripts with different parts and functions all in the same place. It's getting messy trying to make a new HUD!
-
23 minutes ago, Rolig Loon said:
It's certainly cleaner from the user's point of view, as well as the scripter's. It's essentially just a different form of llDialog.
Just tried it instead of the typing channel. Much better Now to figure out the other stuff...
-
17 minutes ago, Rolig Loon said:
I assume that the llRequestPermissions line has only temporarily been commented out.
oh yes! Forgot to fix that before pasting it here. I was just trying to debug things earlier. Is llTextBox better than a listener channel?
Doing Maths calcuations in LSL - help!
in LSL Scripting
Posted
Thanks, that worked now! I'm more of a PHP coder so it didn't even occur to me to cast them as floats if they were already integers, as this calculation works fine in PHP (I checked to make before I posted the OP to make sure my maths was correct!).
Anyway, this now gives the right result: