In this tutorial, I shall demonstrate how to create an ammo counter in TombEngine.

In order to fully complete this tutorial you need knowledge of:

  • a basic understanding of how variables works
  • a basic understanding of how decision-making works (if else statement work)
  • a basic understanding of logical operators.
LevelFuncs.OnControlPhase = function()
    ShowAmmoCounter()
end

function ShowAmmoCounter()
    local ammoCounterPosX = 100 -- X Position of counter.
    local ammoCounterPosY = 300 -- Y Position of counter.
    local holdWeapon = Lara:GetHandStatus() -- Check Lara's hand status.
    local ammoCounterColor = Color.new(--[[Insert RGB values]]) 
    local ammoMessage = DisplayString(
    "Ammo: "..holdWeapon, ammoCounterPosX,
    ammoCounterPosY, ammoCounterColor)

    if (Lara:GetAmmoCount() == -1) then
        unlimited = true
    else
        unlimited = false
    end

    if not unlimited then
        if holdWeapon == 4 then
            ShowString(ammoMessage)
        else
            HideString(ammoMessage)
        end
    end
end