Skip to content

Conversation

Dgrouse96
Copy link
Contributor

Added blueprint functions for lua states, added LuaStateComponent for an instantiation example

LuaStateComponent could possibly be merged with LuaComponent, up to you. Left out http functions for now, you should look into it later.

Copy link

@fidyeates fidyeates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it out and seems to be working well - however quite a serious garbage collection issue when you don't reference the LuaState within blueprints / elsewhere.


LuaState = NewObject<ULuaState>(this, LuaStateClass);
LuaState->GetLuaState(GetWorld());
LuaState->ReceiveLuaLevelAddedToWorld(GetOwner()->GetLevel(), GetWorld());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe here we're going to want to add:

LuaState->AddToRoot();

With a corresponding ->RemoveFromRoot(); on a destructor/DestroyLuaState().

Without this the LuaState will get garbage collected out from under you if you don't reference it anywhere in blueprints.

Ran into this issue as we were only accessing it via the pure getters.

Copy link
Contributor Author

@Dgrouse96 Dgrouse96 May 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend just adding the UPROPERTY macro above the lua state reference, this should keep it protected from garbage collection as long as the outer is the LuaStateComponent

@rdeioris
Copy link
Owner

rdeioris commented Jun 7, 2021

@Dgrouse96 I like it, i will need a bit to merge it as i want it to became a first citizen in the plugin so i need to do a bit of refactoring of other parts of the code.

@rdeioris
Copy link
Owner

@Dgrouse96 starting another attempt at merging it, sorry again for the huge late :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants