why can't I get a checkpoint to flash with a script? - roblox

I am trying really hard to start with a simple skeleton on Roblox Studio, and then change one of the checkpoints (or all of them) so that they flash.
I thought to do that by using a script that I saw online that changes the transparency from 1 to 0 and back every 1 second.
So I tried this (I added this to all Checkpoints quite consistently in the same way):
and this (for this one I just added the part at the bottom):
but whenever I played in the Studio to test it I always got static checkpoints:
It is either the script is not running, or transparency is not the right way to go or what?

The "Checkpoints" folder has many objects in it that are called "Checkpoint". If you want to flash a particular one from its child script, you could do this instead:
while (true) do
script.Parent.Transparency = 1
wait(1)
script.Parent.Transparency = 0
wait(1)
end
it will only flash its parent (the Checkpoint).

Related

Is there any option of running an Anylogic simulator without opening any UI window?

I'm in a project in which I have to run an Anylogic simulator multiple times. I made an script to modify the input data, run the simulator and then store the output data just before the next simulation run.
The idea is to externally run the simulation (from a python file). The problem is that, when the simulation ends, the simulation window doesn't close automatically so the python file won't continue executing.
I´ve tried to run the simulator without showing the animation of the simulation but still opens a window so it doesn´t work for my purpose.
I don´t know if there is an option in Anylogic to export a model that automatically closes the window once the simulation is completed or if there is any way of creating a simulator that runs without opening any window.
Thank you.
Unfortunately there is no such solution. Even if you can run without UI in Linux, it will not automatically close once the run is complete. I use a workaround:
It is a Python script that scans the outputs folder every 5 seconds and if there are changes in the files, it closes the AnyLogic file. Use this as an inspiration::
from time import sleep
from utils.data.fileSystem import FileSystem
def sync_polling_folder(path, predicate, delay_sec):
print('checking under ' + path + ' folder')
beginning = FileSystem.stat(path)
old = beginning
new = beginning
def two_files_are_different():
return not predicate(str(old), str(new))
def the_process_has_not_begun():
return str(new) == str(beginning) or str(old) == str(beginning)
# if two folders are the same, quit (means no-changes = finished)
# but if they are equal because process never started, keep going
while two_files_are_different() or the_process_has_not_begun():
print('[sleeping] because files are not written yet.')
sleep(delay_sec) # main thread waiting
old = new
new = FileSystem.stat(path)
print('[anylogic] ready to be killed')
return True

How to force the next node to visit in VRPTWs without changing time window

Let's say I have 3 pairs of pickup and delivery(6 nodes), and their own time windows.
0-Node_start #Index(0)
1-Pickup, 2-Delivery #Index(1,2)
3-Pickup, 4-Delivery #Index(3,4)
5-Pickup, 6-Delivery #Index(5,6)
7-Node_end #Index(7)
How can I force my vehicle to go from node start to index_3, then continue with the rest of the route directly without changing the time window of a node in index_3, or changing the traveling time to 0 from node_0 to node_3? This should be possible regardless of the time taken from index_0 to index_3, as long as time windows allow.
Also, not sure if this is important in this case, but I use FirstSolutionStrategy.GLOBAL_CHEAPEST_ARC
I have found a solution that works for my case, hopeful it will work for others too. I used NextVar
consecutive_locations = [[1,3], [7,9]]
for location_index in consecutive_locations:
routing.solver().Add(routing.NextVar(location_index[0]) == location_index[1])
I used a loop because I have multiple vehicles, each vehicle has a specific starting point, and a location I want it to visit next after starting point.
The solution takes longer though, I think firstSolutionStrategy might be the issue(Not sure)

MIT-Scratch : Sequential cloning without delay

I am just starting to play with this as an educational tool for a youngster and encounter strange behavior whilst attempting to clone sprites.
I setup a global variable for position x,y in sprite_1 and clone a sprite_2 object. This object immediately copies the global x,y to local x,y and exits. Later sprite_2 renders using the stored local x,y.
sprite_1:
sprite_2:
I expect the four sprites to clone diagonally up/right on the screen according to this small reproduce-able example. Instead I appear to get four sprite_2 objects all on top of each other:
If I add a delay of 1 second onto the end of the clone(x,y) function however all is well:
As all four sprite_2 objects appear to be where the last clone was placed, I have a suspicion that the clones are not created immediately but instead created as a batch all at once, at some time and therefore are all taking the last coordinates from the globals _clone_enemy_x/y.
Is this the case? is there are way to circumvent this behavior or what is the solution?
I have 2 possible solutions to this problem:
Go to the "define clone()()" block, right click it, open up the advanced dropdown, and tick "run without screen refresh".
Get rid of the custom block all together, but use the original source for that block in the actual code.
I hope this helps!

Editing Timeline from CCB file in cocos

I did some research into this and couldn't really find anything, so if this is a repetitive question I apologize. but anyway I have made a CCB file in CocosBuilder and I would like to start the timeline, for example, at one second instead of playing from the beginning. Is there a way to do this? Thanks for the help guys.
Edit: i would like this to be done in the code.
I am using 2.2.1 Cocos2DX version. I think there is no option to play it from given interval. But you can tweak yourself to get it done. (Not simple one)
You have to go to CCBAnimationManager and there you get "mNodeSequences".
It is dictionary and you get difference properties there like "rotation position etc..."
values there.
Internally AnimationManager reads this value (These values are specified in your CCB)
and puts in runAction queue.
So you have to break it as you want.(Ex. 5 min timeline you have. But you want to start
from 1 min then you have run first 1 min Actions without delay and for remaining you
have properly calculate tween intervals.
It's long procedure and needs calculation. If you don't know any other simpler way try this. If you know pls let us know (Post it).

EF6/Code First: Super slow during the 1st query, but only in Debug

I'm using EF6 rc1 with Code First strategy, without precompiled views and the problem is:
If I compile and run the exe application it takes like 15 seconds to run the first query (that's okay, since I'm still working on the pre-generated views). But if I use Visual Studio 2013 Preview to Debug the exact same application it takes almost 2 minutes BEFORE running the first query:
Dim Context = New MyEntities()
Dim Query = From I in Context.Itens '' <--- The debug takes 2 minutes in here
Dim Item = Query.FirstOrDefault()
Is there a way to remove this extra time? Am I doing something wrong here?
Ps.: The context itself is not complicated, its just full with 200+ tables.
Edit: Found out that the problem is that during debug time the EF appears to be generating the Views ignoring the pre-generated ones.
Using the source code from EF I discovered that the property:
IQueryProvider IQueryable.Provider
{
get
{
return _provider ?? (_provider = new DbQueryProvider(
GetInternalQueryWithCheck("IQueryable.Provider").InternalContext,
GetInternalQueryWithCheck("IQueryable.Provider").ObjectQueryProvider));
}
}
is where the time is being consumed. But this is strange since it only takes time in debug. Am I missing something here?
Edit: Found more info related to the question:
Using the Process Monitor (by Sysinternals) I found out that there its the 'desenv.exe' process that is consuming tons of time. To be more specific its consuming time with an 'Thread Exit'. It repeats the Thread Exit stack 36 times. I don't know if this info is very useful, but I saved a '.cvs' with the stack, here is his body: [...] (edit: removed the '.cvs' body, I can post it again by the comments if someone really think its going to be useful, but it was confusing and too big.)
Edit: Installed VS2013 Ultimate and Entity Framework 6 RTM. Installed the Entity Framework Power Tools Beta 4 and used it to generate the Views. Nothing changed... If I run the exe it takes 20 seconds, if I 'Start' debugging it takes 120 seconds.
Edit: Created a small project to simulate the error: http://sdrv.ms/16pH9Vm
Just run the project inside the environment and directly through the .exe, click the button and compare the loading time.
This is a known performance issue in Lazy (which EF is using) when the debugger is attached. We are currently working on a fix (the current approach we are looking at is removing the use of Lazy). We hope to ship this fix in a patch release soon. You can track progress of this issue on our CodePlex site - http://entityframework.codeplex.com/workitem/1778.
More details on the coming 6.0.2 patch release that will include a fix are here - http://blogs.msdn.com/b/adonet/archive/2013/10/31/ef6-performance-issues.aspx
I don't know if you have found the solution. But in my case, I had similar issue which wasted me close to a week after trying different suggestions. Finally, I found a solution by changing my web.config to optimizeCompilations="true" and performance improved dramatically from 15-30 seconds to about 2 seconds.