Page 1 of 1

Can't goto state label

Posted: Sun Jan 07, 2018 5:47 am
by PrinceOfFunky
Maybe I forgot how to use them since I almost never did it, but I cannot call GotoState() on a label, or at least, the log inside it is not called, this is the code:

Code: Select all

auto state LookForHeatMap {
	event BeginState() {
		Log(0);
		GotoState('LookForHeatMap', 'LookFor');
		Log(1);
	}

LookFor:
	Log(2);
}
Logs 0 and 1 are printed, but '2' isn't. Am I doing it wrong?

Re: Can't goto state label

Posted: Sun Jan 07, 2018 12:12 pm
by Feralidragon
Not sure, but I would say that GotoState calls are ignored during BeginState and EndState, since these are called during GotoState already.

Re: Can't goto state label

Posted: Sun Jan 07, 2018 6:13 pm
by PrinceOfFunky
Feralidragon wrote:Not sure, but I would say that GotoState calls are ignored during BeginState and EndState, since these are called during GotoState already.
Mhm, I doubt it's like that tho. GotoState() is not even an event, so it cannot be programmatically ignored, unless you're talking about native ignoring, but I don't see why they should have put it.

EDIT: I'm using this workaround now:

Code: Select all

auto state LookForHeatMap {
Begin:
	Log(0);

LookFor:
	Log(1);
}

Re: Can't goto state label

Posted: Sun Jan 07, 2018 6:18 pm
by Higor
That is 0/10 tier state coding.
BeginState is executed right as you call GotoState, the engine protects itself from an infinite recursion here, figure it out it's not too difficult.
Second, if you want to start executing script on the state frame, add a 'Begin:' label and it'll start executing during next tick update.

Re: Can't goto state label

Posted: Sun Jan 07, 2018 6:24 pm
by PrinceOfFunky
Higor wrote:That is 0/10 tier state coding.
BeginState is executed right as you call GotoState, the engine protects itself from an infinite recursion here, figure it out it's not too difficult.
Second, if you want to start executing script on the state frame, add a 'Begin:' label and it'll start executing during next tick update.
Thanks, that was the workaround I used, anyway I wanted an infinite recursion(almost), I needed a loop, but using 'while' looked too much CPU consuming, I guess it's the same with a state loop.

Re: Can't goto state label

Posted: Sun Jan 07, 2018 9:38 pm
by Barbie
An infinite recursion is another thing than an infinite loop... :D
It looks like you want to code a kind of polling - what do you want to achieve? Maybe there is a better solution than polling.

Re: Can't goto state label

Posted: Sun Jan 07, 2018 9:58 pm
by PrinceOfFunky
Barbie wrote:An infinite recursion is another thing than an infinite loop... :D
It looks like you want to code a kind of polling - what do you want to achieve? Maybe there is a better solution than polling.
What I'm doing is:
- Call an external script that has to write a file.
- Loop to check if the file has been created.
The old way didn't have a CPU consuming flow:
- Send a TCP message to an external software to write a file.
- Do nothing until the external software sends you a TCP message to tell it finished writing the file.

But I don't want to use TCP, even if less invasive.

Re: Can't goto state label

Posted: Sun Jan 07, 2018 10:52 pm
by papercoffee
I somehow don't like the sound of this.
What exactly is your goal?

Re: Can't goto state label

Posted: Mon Jan 08, 2018 3:06 am
by PrinceOfFunky
papercoffee wrote:I somehow don't like the sound of this.
What exactly is your goal?
? Taking over your laptops of course...

Jk, it's for the HeatMap:
PrinceOfFunky wrote:

Code: Select all

state LookForHeatMap
It all works anyway, it's just that Idk if to revert the changes and use TCP back, to avoid the CPU consuming loop.

Re: Can't goto state label

Posted: Mon Jan 08, 2018 3:35 am
by papercoffee
PrinceOfFunky wrote:
papercoffee wrote:I somehow don't like the sound of this.
What exactly is your goal?
? Taking over your laptops of course...

Jk, it's for the HeatMap:
PrinceOfFunky wrote:

Code: Select all

state LookForHeatMap
It all works anyway, it's just that Idk if to revert the changes and use TCP back, to avoid the CPU consuming loop.
I don't have a laptop ...I'm interneting with a potato. :ironic:

No ...I'm just curious why you need to write a file on the clients machine from outside?

Re: Can't goto state label

Posted: Mon Jan 08, 2018 7:05 am
by PrinceOfFunky
papercoffee wrote:I'm interneting with a potato.
If you're using GLaDOS, that's surely better than a laptop.
papercoffee wrote:I'm just curious why you need to write a file on the clients machine from outside?
No, I need to write it server-side, the heatmaps must be written.

EDIT:
PrinceOfFunky wrote:What I'm doing is:
- Call an external script that has to write a file.
- Loop to check if the file has been created.
The detailed flow was like:
- Call an external script that has to look for a file 'A' and if found write a file 'B' containing the name of the file 'A'.
- Loop while trying to localize file 'B'.
- When localized, read the name of the file 'A' from inside 'B'.
Sadly, this is not doable cause Unreal caches the INT files it reads, and so the file 'B' would contain the same name for the file 'A' everytime Unreal would try to access it in the same session.
So TCP is the way, since I don't want to revert everything back, I'll try making a hybrid lol.

Re: Can't goto state label

Posted: Mon Jan 08, 2018 2:39 pm
by papercoffee
:tu: Ok, thanks for the clarification.

Re: Can't goto state label

Posted: Mon Jan 08, 2018 5:14 pm
by Barbie
PrinceOfFunky wrote:So TCP is the way
Otherwise the sleep() command could has been useful; something like this (untested):

Code: Select all

auto state WaitForIt {

begin:
	if (WaitMore())
	{
		sleep(1);
		goto('begin');
	}
	// processing code here
}

Re: Can't goto state label

Posted: Mon Jan 08, 2018 8:17 pm
by PrinceOfFunky
Barbie wrote:
PrinceOfFunky wrote:So TCP is the way
Otherwise the sleep() command could has been useful; something like this (untested):

Code: Select all

auto state WaitForIt {

begin:
	if (WaitMore())
	{
		sleep(1);
		goto('begin');
	}
	// processing code here
}
Thanks, I'll try it right now.
EDIT: Awesome! The CPU usage decreases a lot for UT with the consequence that the external script isn't slowed down by the UT CPU usage, so everything goes faster.
(UT CPU usage while looping: Without Sleep() = ~15/20%; With Sleep() = ~4.5/6%.)

lil update: There's no need to use TCP now, I added this to the beginning of the flow:
- Write a "known" file that will contain the name of the file 'B'.
This way the file 'B'(containing the name of the heatmap file) will never be cached by Unreal, it will be everytime different.