Skip to content

Item / function to get player position and rotation data #154

@jig487

Description

@jig487

Describe your idea

Currently I'm working on a Hologram API that will let you define things in the 3d maths space of minecraft coordinates and then render them in the AR goggles. A command that grabs the position and rotation of the player would be immensely helpful, and I'm sure would have uses outside of what I'm doing.

Describe alternatives you've considered if you've any

Currently this function is what I've been using to get the player pos and rot data.

local function getData()) --Grabs player head rotation and pos
    local _, rot = commands.exec("data get entity "..playerName.." Rotation")
    local rot = string.match(textutils.serialize(rot[1]) , "%d+%p+%d" , 33 + #playerName)--This doesn't work yet. Need to fix the string match
    for i = 1, 3 do
        _, playerPos[i] = commands.exec("data get entity "..playerName.." Pos["..(i-1).."]")
        playerPos[i] = string.match(textutils.serialize(playerPos[i]) , "%d+%p+%d" , 32 + #playerName) --This doesn't work yet. Need to fix the string match
    end
end

Additional context

No response

Linked Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions