Author Topic: How to transfer Added Coins to Game in the main menu  (Read 2871 times)

lazenes

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to transfer Added Coins to Game in the main menu
« on: February 03, 2024, 11:40:19 AM »
I want to use Numpad 1 as a token eject button, but even though I press the button 1 time, it increases the value of my sayac  variable as if it was pressed more than 1. Is there a function that I can increase it only once? Then I want to add the coins from my Coin Channel on the Attract-Mode Home screen to the user's digit when the game is opened.


Code: [Select]
local sayac = 0

local lcdLeftTextCoin = fe.add_text("COIN: " + sayac, blip*0.4536, blip*0.83, blip*0.8208, blip*0.04)
lcdLeftTextCoin.set_rgb(255, 0, 3)
lcdLeftTextCoin.align = Align.Left
lcdLeftTextCoin.rotation = -12.5
lcdLeftTextCoin.font = "digital-7 (italic)"

fe.add_ticks_callback(this, "tick")

local stringkeys = "1"

local keys = {}
foreach(letter in stringkeys) {
   keys[letter.tochar()] <- false
}


function tick(tick_time){
   foreach(key, value in keys) {
      local yeniDurum = fe.get_input_state("Num" + key)
      if (yeniDurum != keys[key]) {
         sayac = sayac + 1
      }
      keys[key] = yeniDurum
   }
   lcdLeftTextCoin.msg = "COIN: " + sayac
}