rdeioris / LuaMachine

Unreal Engine Plugin for Lua APIs implementation
MIT License
581 stars 120 forks source link

Lua Run File Doesnt Work #25

Open kstzl opened 3 years ago

kstzl commented 3 years ago

Hello, lua run file doesnt seem to work :

image image image

It say nil :/

kstzl commented 3 years ago

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

rdeioris commented 3 years ago

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

kstzl commented 3 years ago

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

kstzl commented 3 years ago

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

rdeioris commented 3 years ago

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.

kstzl commented 3 years ago

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

rdeioris commented 3 years ago

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)

kstzl commented 3 years ago

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

kstzl commented 3 years ago

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

kstzl commented 3 years ago

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