Lua Help

Novice_

Новичок
Автор темы
5
1
func.png

Why the functions are passed as parameters? It's an advantage?
 

Novice_

Новичок
Автор темы
5
1
1638668018402.png

Why is like that and not like
function exemple_function()
-- code
end

Why function is passed as another function argument?
 

copypaste_scripter

Известный
1,218
223
no idea what u mean by passing, but function is "used" once by script, if it was used by command it would be given name as you wrote to "call" it when needed.
here, function is just getting value if player is playing by built in game activity library and returning value
i think i got it right, if not someone will correct me
 
  • Нравится
Реакции: Novice_

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,891
1,253

Novice_

Новичок
Автор темы
5
1
Посмотреть вложение 125195
Because the OnFrame function needs parameters like this

In your screenshot, a lambda function is passed to OnFrame, it doesn't need a name. Instead of a lambda, you can also use a pre-initialized function by its name
Thank you, i didn't know this thing is named `lambda`. But how is possible to use that type of lambda functions in OnFrame? Because i tryed to do another script with a lambda function as argument, and it didn't work.
1638669001986.png

1638669017062.png
 

#Northn

Police Helper «Reborn» — уже ШЕСТЬ лет!
Всефорумный модератор
2,633
2,482
  • Нравится
Реакции: Novice_

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,891
1,253
Thank you, i didn't know this thing is named `lambda`. But how is possible to use that type of lambda functions in OnFrame? Because i tryed to do another script with a lambda function as argument, and it didn't work.
Посмотреть вложение 125196
Посмотреть вложение 125197
Lua:
function a(func)
    print(type(func), func())
end

a(function() return "any value" end) -- a lambda will be passed to the function
 
  • Влюблен
Реакции: Novice_