Hyunsu Posted February 15, 2011 Share Posted February 15, 2011 (edited) "A" is big resource. "B" is 1kb resource. i want to start "B" after starting "A". but i can't. -- script in "A" resource. function startingB() startResource(getResourceFromName("B")); end addEventHandler("onResourceStart", getResourceRootElement(), startingB); -- at Console , (i typed "start A") starting "A" starting "B" start: Resource "B" stated start: Resource "A" stated i want to add "FinishedStarting". Edited February 15, 2011 by Guest Link to comment
Castillo Posted February 15, 2011 Share Posted February 15, 2011 I'm not sure of what are you trying to say, but getResourceState includes many states, such as: loaded, starting. So i don't really get what do you mean. Link to comment
diegofkda Posted February 15, 2011 Share Posted February 15, 2011 "A" is big resource."B" is 1kb resource. i want to start "B" after starting "A". but i can't. -- script in "A" resource. function startingB() startResource(getResourceFromName("B")); end addEventHandler("onResourceStart", getResourceRootElement(), startingB); -- at Console , (i typed "start A") starting "A" starting "B" start: Resource "B" stated start: Resource "A" stated i want to add "onResourceStarted". or add return of getResourceState a "started". onResourceStart and onResourceStarted... IS NOT THAT THE SAME THING!?!?? Link to comment
Lex128 Posted February 15, 2011 Share Posted February 15, 2011 You want to run B after start up the server? If so, try using a timer. I have the same problem and I solved it using a timer 50ms Link to comment
Hyunsu Posted February 15, 2011 Author Share Posted February 15, 2011 (edited) You want to run B after start up the server?If so, try using a timer. I have the same problem and I solved it using a timer 50ms yes, it's my wanting. but, that's not safe. we don't know when resource finished starting. Edited February 15, 2011 by Guest Link to comment
Hyunsu Posted February 15, 2011 Author Share Posted February 15, 2011 (edited) I'm not sure of what are you trying to say, but getResourceState includes many states, such as: loaded, starting.So i don't really get what do you mean. sorry, my bad english. i already did getResourceState. "when resource start" and "when resource finished starting" were always "running". not changed. Edited February 15, 2011 by Guest Link to comment
Hyunsu Posted February 15, 2011 Author Share Posted February 15, 2011 onResourceStart and onResourceStarted... IS NOT THAT THE SAME THING!?!?? maybe i think that .. when start resource("onResourceStart" ) -> starting.. - > starting.. -> when finished starting resource("onResourceStarted") Link to comment
12p Posted February 15, 2011 Share Posted February 15, 2011 What do you exactly want to do, with that event? Maybe you could do a script for that, instead of using that event: addEventHandler ( "onResourceStart", getRootElement ( ), function ( ) setTimer ( triggerEvent, 500, 1, "onResourceStarted", getResourceRootElement ( ) ) end ) Or something like that, I don't know hehe Link to comment
diegofkda Posted February 15, 2011 Share Posted February 15, 2011 You want to run B after start up the server?If so, try using a timer. I have the same problem and I solved it using a timer 50ms yes, it's my wanting. but, that's not safe. we don't know when resource finished starting. Try to scale the file-size with timers. If file-size is 10 kb, use setTimer 500, if its 1 mb, try to use 1000. If the resource is 1 kb, use just 50. Link to comment
12p Posted February 15, 2011 Share Posted February 15, 2011 Yep. The code I gave was an idea about how to do it Link to comment
lil Toady Posted February 16, 2011 Share Posted February 16, 2011 That's not how it works, resource A should be a dependency of resource B specified in the meta.xml Link to comment
eAi Posted February 16, 2011 Share Posted February 16, 2011 If A is a dependency of B in meta.xml, it won't start until A has started. Link to comment
Recommended Posts