Я хочу сделать это, когда я нажимаю кнопку, меняется переменная переменных.Изменение переменной в функции
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