Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Conversation

@LPGhatguy
Copy link
Owner

@LPGhatguy LPGhatguy commented Jul 8, 2018

This PR takes advantage of the new task scheduler to cause Script (and now LocalScript) objects to schedule themselves to execute when parented to a DataModel.

This logic is right now sort of shaky. I'm not confident that it's correct right now.

Things to do before merge:

  • Port checks to FindFirstAncestorWhichIsA
  • Verify that this behavior (scripts begin executing when parented) is correct
  • Figure out whether scripts should push a task into the scheduler or immediately run
  • Handle error cases correctly:
    • Parsing errors
    • Runtime errors before the initial yield, which is the job of the initial caller if not using the task scheduler
  • Add a method here or in a future PR to explicitly start stepping through all tasks, including scripts

@coveralls
Copy link

coveralls commented Jul 8, 2018

Coverage Status

Coverage decreased (-0.5%) to 97.22% when pulling 80a5725 on runnable-scripts into 42e609e on master.

local game = nil

local now = instance
while now do
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of this whole loop? If you really can't just use the game global, changing this to now:FindFirstAncestorWhichIsA("DataModel") would make this more readable.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Right, there is no game global here, since we have no environment.

I forgot that FindFirstAncestorWhichIsA was a function we have, that's the way to go. I'll remove the existing ScreenGui checks and replace them with that too.

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, FindFirstAncestorWhichIsA isn't actually implemented on lemur. Wouldn't be hard though.

@LPGhatguy LPGhatguy changed the title Make Script schedule itself to run when parented to a DataModel WIP: Make Script schedule itself to run when parented to a DataModel Aug 13, 2018
@Kampfkarren
Copy link
Contributor

Kampfkarren commented Sep 13, 2018

Make sure it doesn't run when it shouldn't, by the way (I think only in ReplicatedStorage?). I have plenty of scripts in ReplicatedStorage for placeholder reasons that don't run.

Edit: ServerStorage too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants