Can't goto state label

Discussions about Coding and Scripting
Post Reply
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Can't goto state label

Post 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?
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Can't goto state label

Post by Feralidragon »

Not sure, but I would say that GotoState calls are ignored during BeginState and EndState, since these are called during GotoState already.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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);
}
Last edited by PrinceOfFunky on Sun Jan 07, 2018 6:21 pm, edited 1 time in total.
"Your stuff is known to be buggy and unfinished/not properly tested"
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Can't goto state label

Post 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.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Can't goto state label

Post 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.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Can't goto state label

Post by papercoffee »

I somehow don't like the sound of this.
What exactly is your goal?
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Can't goto state label

Post 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?
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Can't goto state label

Post by papercoffee »

:tu: Ok, thanks for the clarification.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Can't goto state label

Post 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
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Can't goto state label

Post 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.
"Your stuff is known to be buggy and unfinished/not properly tested"
Post Reply