Advertisement
jaklsfjlsak

o3生成 虚拟助理

Mar 13th, 2025
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. -- Wrap the Virtual Assistant peripheral (adjust side name as needed)
  2. local assistant = peripheral.find("warpdriveVirtualAssistant") or peripheral.wrap("left")
  3. if not assistant then
  4.   error("No Virtual Assistant found. Attach the block to the computer.")
  5. end
  6.  
  7. -- (Optional) Configure the listening range
  8. local defaultRange = assistant.getRange()
  9. print("Assistant ready. Current range: "..defaultRange.." blocks.")
  10. -- assistant.setRange(20)  -- for example, limit range to 20 if desired
  11.  
  12. print("Listening for chat messages...")
  13. while true do
  14.   -- Wait for a chat message event from the Virtual Assistant
  15.   local event, playerName, message = os.pullEvent("message")
  16.   -- 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)
  17.  
  18.   -- Check if the message matches the save-point format
  19.   if message then
  20.     local label, x, y, z, dim = string.match(message, '%[name:"([^"]+)",%s*x:(-?%d+),%s*y:(-?%d+),%s*z:(-?%d+),%s*dim:(-?%d+)%]')
  21.     if label and x and y and z and dim then
  22.       -- Convert numeric strings to numbers
  23.       x, y, z, dim = tonumber(x), tonumber(y), tonumber(z), tonumber(dim)
  24.       print(("%s tagged save point '%s' at X=%d, Y=%d, Z=%d in dimension %d"):format(playerName, label, x, y, z, dim))
  25.       -- (You could add code here to save these coordinates or perform another action)
  26.     else
  27.       -- Not a formatted save point command; just print the chat for logging
  28.       print(("<%s> %s"):format(playerName, message))
  29.     end
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement