1
我想在按下按钮时使一堆变量发生变化。更改函数中的变量
function BuyItem(price, quantity, pps, text, quantitytext)
if(PixoosQuantity >= price) then
PixoosQuantity = PixoosQuantity - price
price = price * 1.1
quantity = quantity + 1
PixoosPerSecond = PixoosPerSecond + pps
PixoosPerSecondDisplay.text = "PPS: " .. string.format("%.3f", PixoosPerSecond)
PixoosQuantityDisplay.text = "Pixoos: " .. string.format("%.3f", PixoosQuantity)
text.text = "Deck of playing cards\nPrice: " .. string.format("%.3f", price) .. " Pixoos"
quantitytext.text = quantity
end
end
这是其能够顺利通过按下按钮调用的函数:
function ButtonAction(event)
if event.target.name == "DeckOfPlayingCards" then
BuyItem(DeckOfPlayingCardsPrice, DeckOfPlayingCardsQuantity, DeckOfPlayingCardsPPS, DeckOfPlayingCardsText, DeckOfPlayingCardsQuantityText)
end
end
我的问题是,为什么不变量的变化?我试图把return price
等,但它仍然无法正常工作......
问题是我不仅需要更改价格,还需要更改数量,文本和数量文本。我怎样才能在一个功能中完成所有功能?甚至有可能吗? – FICHEKK
在Lua中,您可以返回更多值并将其分配给适当的变量。我修改了答案。 – Jakuje
你是一个兄弟!谢谢你,兄弟!这解决了它! – FICHEKK