【发布时间】:2020-03-27 04:31:02
【问题描述】:
bulletsPlayer1 = {
Pistol = {},
Shotgun = {}
}
bulletsPlayer2 = {
Pistol = {},
Shotgun = {}
}
我有这些表格,我有这个功能来创建项目符号:
function createBullet(x, y, angle, speed, weapon, player)
local directionx = speed * math.cos(angle)
local directiony = speed * math.sin(angle)
table.insert(
"bulletsPlayer"..player.."."..weapon,
{
positionx = x,
positiony = y,
directionx = directionx,
directiony= directiony,
speed = speed
}
)
end
例如,如果我这样调用这个函数
createBullet(100,100,0,300,'Shotgun',1)
我收到此错误:
shooting.lua:77: 'insert' 的参数 #1 错误(应为表,得到字符串)
如何让我的代码将 table.insert() 的第一个参数识别为我的表而不是字符串?
【问题讨论】:
标签: string lua arguments concatenation