Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wrap the Virtual Assistant peripheral (adjust side name as needed)
- local assistant = peripheral.find("warpdriveVirtualAssistant") or peripheral.wrap("left")
- if not assistant then
- error("No Virtual Assistant found. Attach the block to the computer.")
- end
- -- (Optional) Configure the listening range
- local defaultRange = assistant.getRange()
- print("Assistant ready. Current range: "..defaultRange.." blocks.")
- -- assistant.setRange(20) -- for example, limit range to 20 if desired
- print("Listening for chat messages...")
- while true do
- -- Wait for a chat message event from the Virtual Assistant
- local event, playerName, message = os.pullEvent("message")
- -- event name "message" is expected from WarpDrive Virtual Assistant [oai_citation_attribution:9‡github.com](https://github.com/JajaSteele/WD-VirtualAssistant/blob/main/assistant.lua#:~:text=match%20at%20L1245%20_%2C%20_%2C,message)
- -- Check if the message matches the save-point format
- if message then
- local label, x, y, z, dim = string.match(message, '%[name:"([^"]+)",%s*x:(-?%d+),%s*y:(-?%d+),%s*z:(-?%d+),%s*dim:(-?%d+)%]')
- if label and x and y and z and dim then
- -- Convert numeric strings to numbers
- x, y, z, dim = tonumber(x), tonumber(y), tonumber(z), tonumber(dim)
- print(("%s tagged save point '%s' at X=%d, Y=%d, Z=%d in dimension %d"):format(playerName, label, x, y, z, dim))
- -- (You could add code here to save these coordinates or perform another action)
- else
- -- Not a formatted save point command; just print the chat for logging
- print(("<%s> %s"):format(playerName, message))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement