Jump to content

Recommended Posts

Is some more ergonomic way to |execute something within frame| than adding and removing event handler ?

 

Answer:

on Community wiki ("Unscheduled Environment", "Where code starts unscheduled")

|isnil|

isnil{systemchat str diag_frameNo;}
//sp: 0.0053ms

 

(edited from: "Is some more ergonomic way to execute something within next frame than adding and removing event handler ?")

Share this post


Link to post
Share on other sites

A waitUntil should work framewise

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites
22 minutes ago, Ilias48rus said:

Is some more ergonomic way to execute something within next frame than adding and removing oneachframe event handler ?

A simple bool check should suffice.

 

Cheers

Share this post


Link to post
Share on other sites
2 hours ago, sarogahtyp said:

A waitUntil should work framewise

sent from mobile using Tapatalk

Yes, working, thank you

 

1 hour ago, Grumpy Old Man said:

A simple bool check should suffice.

 

Cheers

What you mean ? ("bool check")

(if you mean ex:

if(|code|)then{};

then there is a problem: not possible to use it for multiline script (use |;| character))

 

Just for possible other future readers, what is other ways to execute code within frame ?

Share this post


Link to post
Share on other sites
11 minutes ago, Ilias48rus said:

Yes, right, thank you

 

What you mean ? ("bool check")

 

Just for possible other future readers, what other ways to execute code within frame ?

What now? Do you want something to execute on the next frame or within the same frame?

You're contradicting yourself.

 

To have something execute on the next frame simply do a bool check that sets itself to false after being executed. Best done inside an eachFrame eventhandler like this:

if (missionnamespace getVariable ["Somevariable",false]) then {systemchat str diag_tickTime;missionnamespace setVariable ["Somevariable",false]};

 

Now when you want to do a check on the next frame simply set "Somevariable to true", on the next frame the code within the "if" statement will be executed.

 

Cheers

 

Share this post


Link to post
Share on other sites
3 hours ago, sarogahtyp said:

A waitUntil should work framewise

sent from mobile using Tapatalk

sorry, bit mistaked when tested, no, it doesn't execute within frame

1 hour ago, Grumpy Old Man said:

Wh..

("within next frame")

 

Found answer on wiki (added to first post)

Share this post


Link to post
Share on other sites
4 hours ago, Ilias48rus said:

Answer:

on Community wiki ("Unscheduled Environment", "Where code starts unscheduled")

|isnil|


isnil{systemchat str diag_frameNo;}
//sp: 0.0053ms

 

 

My test doesn't agree with this.

 

I used:

 

diag_log diag_frameNo; isNil{diag_log diag_frameNo}

 

And got:

 

16:35:17 57386
16:35:17 57386

 

So it executes on the same frame.  

 

It should have been 57386 57387,if you mean you want it to execute on the next frame.  I think what you were measuring is the time taken to execute isNil and systemChat and str.

 

edit:  If you want to execute on the same frame, then just call:

 

diag_log diag_frameNo;diag_log diag_frameNo

 

Try to avoid saying within one frame.  It sounds confusing as it's either the same frame or not.

 

 

edit II:  Even if you start scheduled and use isNil to get into unscheduled, it executes on the same frame:

 

0 spawn {diag_log diag_frameNo;isNil{diag_log diag_frameNo}}

Result:

16:44:45 68628
16:44:45 68628

 

Share this post


Link to post
Share on other sites

If you need the next frame, you can use waituntil like Pythagoras suggested:

 

0 spawn {_frame = diag_frameNo; diag_log _frame; waitUntil {diag_frameNo > _frame};diag_log diag_frameNo}

 

16:50:41 76226
16:50:42 76227

 

Obv if the scheduler is full then that might break, so use EH, FSM, CBA or EachFrame if it means that much to you to be sure, to be sure.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, das attorney said:

..

ok..,-sorry what i unpurposely got you into confusion, but "next" frame is not important in the question, its just speech word, question is in execution within frame:

[]spawn{systemchat str diag_frameNo;
for'_n'from 0 to 100000 do{};
for'_n'from 0 to 100000 do{};
isnil{systemchat str diag_frameNo;
	for'_n'from 0 to 100000 do{};
	for'_n'from 0 to 100000 do{};
systemchat str diag_frameNo;};
}
//887349, 887353, 887353;

 

Thank you for responses

Share this post


Link to post
Share on other sites
7 minutes ago, das attorney said:

I'm glad you found what you came for.

me too :)

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×