Time, and answers that arrive later
The single thing that catches everybody out: asking for something does not mean it has happened yet.
Why a script has to wait
Second Life is somewhere else. When a script asks the avatar to teleport, the request goes to the region and the answer comes back when the region is ready, which is usually a few seconds and occasionally much longer.
Your script does not pause for that on its own. The line after the teleport runs immediately, while the avatar is still going, and if that line assumed it had arrived it is now wrong.
The same is true of information. Ask who is nearby the instant an avatar connects and the list may be short or the names empty, not because nobody is there but because the region has not finished saying so.
Wait, then look again
The pattern is always the same: ask, wait a moment, check, and give up after a sensible number of tries.
import time
avatar.teleport_home()
for attempt in range(30):
time.sleep(1)
status = avatar.execute("get_connection_status")
print(attempt, status)- import time is Python's own, not something NeuraCore adds.
- The teleport is asked for once, before the loop.
- range(30) with a one second sleep is at most thirty seconds of waiting. A loop with no limit is a script that hangs forever when something goes wrong.
- time.sleep pauses this script only. The avatar, the interface and every other avatar carry on.
Keeping something running
A script that should watch for something for a while is the same shape: a loop, a sleep, and a limit. Pick the sleep by how fast the thing you are watching actually changes. Checking who is nearby once a minute is reasonable; checking sixty times a minute is sixty times the work for an answer that barely moved.
Remember that the script ends when NeuraCore closes. For something that must be up whether you are there or not, run NeuraCore on a server in console mode; the topic on running without a window covers it.