我想将数据从 Lua 发送到 C#

I want to send data from Lua to C#

这是 Lua 代码。我想发送 XXPos、YYPos、ZZPos。但是在unity3d中,它只接收XXPos。

  socket = require("socket")
  print(socket._VERSION)

  function dataListener:post( t )

    local XPos = ship.rb:getPosition():x()
    local YPos = ship.rb:getPosition():y()
    local ZPos = ship.rb:getPosition():z()
    local XXPos = math.floor( XPos * 1000 + 0.5 ) / 1000
    local YYPos = math.floor( YPos * 1000 + 0.5 ) / 1000
    local ZZPos = math.floor( ZPos * 1000 + 0.5 ) / 1000

    udp=socket.udp();
    udp:setpeername("127.0.0.1",8051)
    udp:send(XXPos, " ", YYPos, " ", ZZPos);
  end

当我像这样更改 Lua 代码时,

--udp:send(XXPos, " ", YYPos, " ", ZZPos)
  udp:send(string.format("%d; %d; %d",XXPos,YYPos,ZZPos))

数据接收正确。但是这个结果有 1 个数字,比如 3; 5; 2.

如何更改此 Lua 代码?

udp:send(string.format("%d; %d; %d",XXPos,YYPos,ZZPos))

应该是udp:send(string.format("%f; %f; %f",XXPos,YYPos,ZZPos))

注意 %f。这意味着浮动。