Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instanced Lua State System #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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