Facebook
From ezezez, 5 Months ago, written in Plain Text.
This paste is a reply to Re: skibideez from ezezez - view diff
Embed
Download Paste or View Raw
Hits: 165
  1. -- Gets the player's info
  2. local function getPlayerInfo(playerName)
  3.     -- TODO: replace this with a real function that fetches the player's info from the Roblox leaderboard API
  4. end
  5.  
  6. -- Function to set up a motor connected to a port
  7. local function setUpMotor(port, name)
  8.     local gpio = require("gpio")
  9.     gpio.init()
  10.     return gpio.servo(port, name)
  11. end
  12.  
  13. -- Set up motor pins
  14. local motorPins = {12, 13, 14} -- {1:Left Motor, 2:Right Motor, 3:Vertical Motor}
  15.  
  16. -- Initialize gyro
  17. local gyro = setUpMotor(1, "Gyro")
  18.  
  19. -- Set up speed for motors
  20. local speed = 50 -- speed value between 0 and 100
  21.  
  22. -- Target player to follow
  23. local targetPlayer = "Player" -- name of the player to follow
  24.  
  25. -- Function to start targeting a player
  26. function target(playerName)
  27.     targetPlayer = playerName
  28.     print("Now following " .. targetPlayer .. " in leaderboard roblox list.")
  29. end
  30.  
  31. -- Function to stop targeting a player
  32. function stopTargeting()
  33.     targetPlayer = nil
  34.     print("Stopped targetting the player in leaderboard roblox list.")
  35. end
  36.  
  37. -- Main loop
  38. while true do
  39.     if targetPlayer then
  40.         local playerInfo = getPlayerInfo(targetPlayer)
  41.         if playerInfo then
  42.             local targetAngle = math.atan2(playerInfo.Y - 50, playerInfo.X - 50) * 180 / math.pi
  43.             gyro.targetRotationY(targetAngle)
  44.         else
  45.             print("Player not found in leaderboard roblox list.")
  46.         end
  47.     end
  48.     wait(0.05)
  49. end

Replies to Re: Re: skibideez rss

Title Name Language When
Re: Re: Re: skibideez fhu9g9hg9rhjgiowriguow text 5 Months ago.