top of page

AZSTOKE/ALGAZODIK

GameAudio & Art

16

Beginner

AZSTOKe_sample_tableSameFileNum

Get the storage position of the specified file in the array

RANK
SNS SHARE

function Msg(param)

     reaper.ShowConsoleMsg(tostring(param).."\n")

end

function tableSameFileNum(table,file)

     local t = table

     local f = file

     local c = 1

    for x, value in pairs(t) do

          if t[x] == f then

             c = x

            goto e

          else

             c = nil

         end

    end

::e::

return c

end


t = {10,20,30,40,50}

a = tableSameFileNum(t,30)

Msg(a)

function Msg(param)

     reaper.ShowConsoleMsg(tostring(param).."\n")

end


  • Set Msg console output function


function tableSameFileNum(table,file)


  • Define a function to get the position of a string in an array.


local t = table

local f = file

local c = 1


  • Store the argument in a variable and initialize the return value variable (c) to default 1.


for x, value in pairs(t) do

if t[x] == f then

c = x

goto e

else

c = nil

end

end

::e::

return c


  • The process is repeated for the number of elements in the array, and if the value stored in the array matches variable (f), that position is set, otherwise nil is set as the value of variable (c).

To use the API, you need to sign up for a plan.

Download the dedicated API

need to do it.

*SILVER is scheduled to be released in May.

No preparation required

- Script Code -
- Script Image -
- Warm Up -
- Script Detail -
- API -

LUA

​ReaScript File Download 👇

* A dedicated API is required to run this

- Script Image -
bottom of page