LuaMachine icon indicating copy to clipboard operation
LuaMachine copied to clipboard

Lua Run File Doesnt Work

Open kstzl opened this issue 4 years ago • 10 comments

Hello, lua run file doesnt seem to work :

image image image

It say nil :/

kstzl avatar Apr 17 '21 02:04 kstzl

And also, how to call an UFunction from lua with parameters ? Thx

kstzl avatar Apr 17 '21 03:04 kstzl

Hi, LuaRunFile does not run code assets, it runs plain files from the filesystem. To run UFunction you need to register them in the LuaState using LuaValue as arguments

rdeioris avatar Apr 17 '21 03:04 rdeioris

Oh ok, but so, we cant "RunLuaFile" with a .lua in project ?

kstzl avatar Apr 17 '21 04:04 kstzl

Also, i removed some functions in my lua script but they seems to be always here

kstzl avatar Apr 17 '21 05:04 kstzl

You can have .lua files in the content directory but they are completely different from LuaCode Assets. Read: you cannot change the LuaCode asset and expect the .lua file will be changed accordingly, they serves different purposes (one allows after-builds modifications, the other will be hardcoded in the final binary). If you want to edit scripts from Unreal itself, just do not use lua files, but only LuaCode Assets and use LuaRunCodeAsset to load/parse/execute them.

rdeioris avatar Apr 17 '21 05:04 rdeioris

Oh ok, i see thank you, and like i said, i had functions (but i removed it, in the .lua) and the lua stack continue executing it, whats the problem ? I think lua memorized my functions

kstzl avatar Apr 17 '21 05:04 kstzl

It is in the previous answer :) you are changing the code asset instead of the lua files, or (but i doubt about it) you are expecting that just changing the content of the file will be enough for lua (you need to reparse/execute it, you can re-run LuaRunFile or LuaRunCodeAsset multiple times for the same LuaState)

rdeioris avatar Apr 17 '21 05:04 rdeioris

Oh ok sorry i didnt see ! I will check, thank you :)

kstzl avatar Apr 17 '21 05:04 kstzl

LuaRunCodeAsset doesnt resolve the problem LuaRunFile dont found my file.. Ouch :/

kstzl avatar Apr 17 '21 05:04 kstzl

Ok i figured out the "problem", i was calling a function that doesnt exist in my .lua file BUT i was expecting that lua dont care about that

kstzl avatar Apr 17 '21 05:04 kstzl