For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com
I'm stupid. (help with state syntax)
-
LOL_PEANUTS
- OldUnreal Member
- Posts: 11
- Joined: Wed Mar 14, 2007 7:17 pm
I'm stupid. (help with state syntax)
I want to jump from state A to state B. How do I achieve this?
-
Chaos13
- OldUnreal Member
- Posts: 951
- Joined: Sat Feb 16, 2008 10:24 am
-
LOL_PEANUTS
- OldUnreal Member
- Posts: 11
- Joined: Wed Mar 14, 2007 7:17 pm
Re: I'm stupid. (help with state syntax)
Hmm. Unreal is ignoring my request to go to the State. Here's my code:
(sorry about all the logs, i was debugging)
Code: Select all
class PLight expands Light;
var(LightColor) byte LightBrightnessMin;
var(LightColor) byte LightBrightnessMax;
var(Lighting) enum EMoreLightTypes
{
LT_DontOverrideLightType,
LT_Flicker2,
LT_Pulse2
} MoreLightTypes;
var(LT_Flicker2) float TimeSteadyMinimum;
var(LT_Flicker2) float TimeSteadyMaximum;
var(LT_Flicker2) bool OnWhileSteady;
var(LT_Flicker2) int TimesToFlickerMaximum;
var(LT_Flicker2) int TimesToFlickerMinimum;
var(LT_Flicker2) float FlickerTimeOnMinimum;
var(LT_Flicker2) float FlickerTimeOnMaximum;
var(LT_Flicker2) float FlickerTimeOffMinimum;
var(LT_Flicker2) float FlickerTimeOffMaximum;
var bool Clock;
var float TimesToFlicker;
var int FlickerCounter;
simulated function PostBeginPlay()
{
log("step 1/10");
if (MoreLightTypes == LT_Flicker2)
{
LightType = LT_Steady;
log("step 2/10");
GotoState('Flicker2');
log("error: PostBeginPlay");
}
}
auto state() Flicker2
{
Begin:
log("step 3/10");
if (OnWhileSteady == true) LightBrightness = LightBrightnessMax;
else LightBrightness = LightBrightnessMin;
log("step 4/10");
Sleep(FRand()*(TimeSteadyMaximum-TimeSteadyMinimum)+TimeSteadyMinimum);
log("step 5/10");
TimesToFlicker = FRand()*(TimesToFlickerMaximum-TimesToFlickerMinimum)+TimesToFlickerMinimum;
FlickerCounter = 0;
log("step 6/10");
While (FlickerCounter < TimesToFlicker) {
log("step 7/10");
Sleep(Frand()*(FlickerTimeOffMaximum-FlickerTimeOffMinimum)+FlickerTimeOffMinimum);
LightBrightness = LightBrightnessMax;
log("step 8/10");
Sleep(Frand()*(FlickerTimeOnMaximum-FlickerTimeOnMinimum)+FlickerTimeOnMinimum);
LightBrightness = LightBrightnessMin;
log("step 9/10");
FlickerCounter += 1;}
log("step 10/10");
GotoState('Flicker2');
log("error: Flicker2");
}
simulated function BeginPlay()
{
if (MoreLightTypes == LT_Flicker2)
Clock = true;
log("error: BeginPlay");
GotoState('Flicker2');
log("error: BeginPlayError2");
}-
Bane
- OldUnreal Member
- Posts: 493
- Joined: Sun Mar 03, 2002 6:32 pm
Re: I'm stupid. (help with state syntax)
at the end of the state, change "gotostate('Flicker2')" to "goto ('Begin')". Additionally, because FLicker2 is declared as 'auto state ...', you don't need to goto it at all. From the logs, I think you were thinking that "gotostate('x')" stops the execution of the code in the calling function. I'm no expert on state code, but I'm sure that's not the case.
Author of Hide and Seek mod, and the NALIBALL mod
Hide and Seek can be downloaded from:
http://HideNSeek.5u.com
Hide and Seek can be downloaded from:
http://HideNSeek.5u.com
-
Chaos13
- OldUnreal Member
- Posts: 951
- Joined: Sat Feb 16, 2008 10:24 am
Re: I'm stupid. (help with state syntax)
I think that to stop execution you must do Goto('');... Oh btw not calling Super.PostBeginPlay(); in PostBeginPlay() and Super.BeginPlay(); in BeginPlay(); is baaaaad, maybe actor was not Inited and not working at ALL. To "restart" a state you must do Goto 'Begin';. Also when calling from function, the state gets switched only *after* the code is returned to state part. That happens AFTER function fully completed. Only if GotoState'd from state its changed instantly.
Last edited by Chaos13 on Tue Mar 18, 2008 3:26 pm, edited 1 time in total.
Skydev = Chaos13 = Dimension4
-
LOL_PEANUTS
- OldUnreal Member
- Posts: 11
- Joined: Wed Mar 14, 2007 7:17 pm
Re: I'm stupid. (help with state syntax)
This is my current code:
class PLight expands Light;
This is what I'm getting:
I did everything everyone told me to, but no matter what I can't get to the Flicker2 State.
class PLight expands Light;
Code: Select all
var(LightColor) byte LightBrightnessMin;
var(LightColor) byte LightBrightnessMax;
var(Lighting) enum EMoreLightTypes
{
LT_DontOverrideLightType,
LT_Flicker2,
LT_Pulse2
} MoreLightTypes;
var(LT_Flicker2) float TimeSteadyMinimum;
var(LT_Flicker2) float TimeSteadyMaximum;
var(LT_Flicker2) bool OnWhileSteady;
var(LT_Flicker2) int TimesToFlickerMaximum;
var(LT_Flicker2) int TimesToFlickerMinimum;
var(LT_Flicker2) float FlickerTimeOnMinimum;
var(LT_Flicker2) float FlickerTimeOnMaximum;
var(LT_Flicker2) float FlickerTimeOffMinimum;
var(LT_Flicker2) float FlickerTimeOffMaximum;
var bool ScriptCheck;
var float TimesToFlicker;
var int FlickerCounter;
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
log("step 1/10");
if (MoreLightTypes == LT_Flicker2)
{
LightType = LT_Steady;
log("step 2/10");
GotoState('Flicker2');
log("error: PostBeginPlay");
}
}
auto state() Flicker2
{
Begin:
log("step 3/10");
if (OnWhileSteady == true) LightBrightness = LightBrightnessMax;
else LightBrightness = LightBrightnessMin;
log("step 4/10");
Sleep(FRand()*(TimeSteadyMaximum-TimeSteadyMinimum)+TimeSteadyMinimum);
log("step 5/10");
TimesToFlicker = FRand()*(TimesToFlickerMaximum-TimesToFlickerMinimum)+TimesToFlickerMinimum;
FlickerCounter = 0;
log("step 6/10");
While (FlickerCounter < TimesToFlicker) {
log("step 7/10");
Sleep(Frand()*(FlickerTimeOffMaximum-FlickerTimeOffMinimum)+FlickerTimeOffMinimum);
LightBrightness = LightBrightnessMax;
log("step 8/10");
Sleep(Frand()*(FlickerTimeOnMaximum-FlickerTimeOnMinimum)+FlickerTimeOnMinimum);
LightBrightness = LightBrightnessMin;
log("step 9/10");
FlickerCounter += 1;}
log("step 10/10");
goto ('Begin');
log("error: Flicker2");
}
simulated function BeginPlay()
{
Super.BeginPlay();
if (MoreLightTypes == LT_Flicker2) {
log("error: BeginPlay");
GotoState('Flicker2');
log("error: BeginPlayError2");}
else {log("error: BeginPlayError3");}
}Code: Select all
ScriptLog: error: BeginPlay
ScriptLog: error: BeginPlayError2
ScriptLog: step 1/10
ScriptLog: step 2/10
ScriptLog: error: PostBeginPlay-
Smartball
- Global Moderator
- Posts: 241
- Joined: Fri Mar 22, 2002 4:01 am
Re: I'm stupid. (help with state syntax)
First off, there's no reason for it to be an auto state, so you can get rid of that. Second off, look at this in Actor.uc:
It does not matter what state you set in PostBeginPlay because SetInitialState will change it anyway. Therefore, instead of
you should have
Next, I noticed that if OnWhileSteady is true, then your code will leave the light on the first time that it is supposed to flicker off. Was that your intention?
I wrote an example for you:
Hope this helps.
Code: Select all
//
// Called after PostBeginPlay.
//
simulated event SetInitialState()
{
if( InitialState!='' )
GotoState( InitialState );
else
GotoState( 'Auto' );
}Code: Select all
GotoState('Flicker2');Code: Select all
InitialState = 'Flicker2';I wrote an example for you:
Code: Select all
class PLight extends Light;
var(Lighting) enum EMoreLightTypes
{
LT_DontOverrideLightType,
LT_Flicker2,
LT_Pulse2
} MoreLightTypes;
var(LightColor) byte LightBrightnessMax, LightBrightnessMin;
var(LT_FLICKER2) int TimesToFlickerMaximum, TimesToFlickerMinimum;
var(LT_FLICKER2) float FlickerTimeOnMinimum, FlickerTimeOnMaximum;
var(LT_FLICKER2) float FlickerTimeOffMinimum, FlickerTimeOffMaximum;
var(LT_FLICKER2) float TimeSteadyMinimum, TimeSteadyMaximum;
var(LT_FLICKER2) bool OnWhileSteady;
var int FlickerCount; // How many times have we flickered?
var int FlickerTotal; // How many times should we flicker?
function PostBeginPlay()
{
Super.PostBeginPlay();
// See what type we're using. LT_Pulse2 and LT_DontOverrideLightType are here for future implementation
switch(MoreLightTypes)
{
case LT_Flicker2:
InitialState = 'Flicker2Steady';
break;
case LT_Pulse2:
case LT_DontOverrideLightType:
}
}
state Flicker2Steady
{
Begin:
log("Entering Flicker2Steady");
if(OnWhileSteady)
LightBrightness = LightBrightnessMax;
else
LightBrightness = LightBrightnessMin;
Sleep(RandRange(TimeSteadyMinimum, TimeSteadyMaximum));
FlickerTotal = RandRange(TimesToFlickerMinimum, TimesToFlickerMaximum);
FlickerCount = 0;
LightBrightness = LightBrightnessMin;
GotoState('Flicker2Off');
}
state Flicker2Off
{
Begin:
log("Entering Flicker2Off");
Sleep(RandRange(FlickerTimeOffMinimum, FlickerTimeOffMaximum));
LightBrightness = LightBrightnessMax;
GotoState('Flicker2On');
}
state Flicker2On
{
Begin:
log("Entering Flicker2On");
Sleep(RandRange(FlickerTimeOnMinimum, FlickerTimeOnMaximum));
if(++FlickerCount < FlickerTotal)
{
LightBrightness = LightBrightnessMin;
GotoState('Flicker2Off');
}
else
GotoState('Flicker2Steady');
}
Last edited by Smartball on Wed Mar 19, 2008 5:48 pm, edited 1 time in total.
Of all the things I've lost, I miss my mind the most.
-
Smartball
- Global Moderator
- Posts: 241
- Joined: Fri Mar 22, 2002 4:01 am
Re: I'm stupid. (help with state syntax)
I actually just copy and pasted your code verbatim to try it, and it went to the Flicker2 state, so I don't know what the issue is (unless you have something specified in the InitialState property).
I also noticed that your code sets the light type to LT_Steady and mine doesn't. That could be fixed with a small change to my PostBeginPlay() function.
I also noticed that your code sets the light type to LT_Steady and mine doesn't. That could be fixed with a small change to my PostBeginPlay() function.
Of all the things I've lost, I miss my mind the most.
-
LOL_PEANUTS
- OldUnreal Member
- Posts: 11
- Joined: Wed Mar 14, 2007 7:17 pm
Re: I'm stupid. (help with state syntax)
Gagh, I'm having the worst of luck.
Despite the fact that it looks perfectly fine, your script didn't work for me either. None of the logs came up.
I know this sounds stupid, but do I have a bad compiler?
Despite the fact that it looks perfectly fine, your script didn't work for me either. None of the logs came up.
I know this sounds stupid, but do I have a bad compiler?
-
Smartball
- Global Moderator
- Posts: 241
- Joined: Fri Mar 22, 2002 4:01 am
Re: I'm stupid. (help with state syntax)
How exactly are you testing it? What I did was I set bNoDelete and bStatic to false (so that I could summon the class in-game) and then I made a text file with this inside:
Summon StateTest.PLight
Set StateTest.PLight MoreLightTypes LT_Flicker2
Set StateTest.PLight LightBrightnessMax 255
Set StateTest.PLight LightBrightnessMin 150
Set StateTest.PLight FlickerTimeOffMaximum 2
Set StateTest.PLight FlickerTimeOffMinimum 1
Set StateTest.PLight FlickerTimeOnMaximum 2
Set StateTest.PLight FlickerTimeOnMinimum 1
Set StateTest.PLight OnWhileSteady true
Set StateTest.PLight TimeSteadyMaximum 5
Set StateTest.PLight TimeSteadyMinimum 1
Set StateTest.PLight TimesToFlickerMaximum 5
Set StateTest.PLight TimesToFlickerMinimum 1
Summon StateTest.PLight
The reason there's two summon calls is because the "Set"s won't work unless the class is in memory, so I summon it once to load it, then I set all the variables, then summon another one. Keep in mind this can't be done if bStatic or bNoDelete are true (which they are in the parent class "Light," which is why I set them to false in PLight).
It's strange to me that "3/10" never appeared in your log with your own code. When I executed your code, I saw it go from 3/10 to 10/10 repeatedly (since it kept looping back to "Begin").
How exactly are you testing the script?
Summon StateTest.PLight
Set StateTest.PLight MoreLightTypes LT_Flicker2
Set StateTest.PLight LightBrightnessMax 255
Set StateTest.PLight LightBrightnessMin 150
Set StateTest.PLight FlickerTimeOffMaximum 2
Set StateTest.PLight FlickerTimeOffMinimum 1
Set StateTest.PLight FlickerTimeOnMaximum 2
Set StateTest.PLight FlickerTimeOnMinimum 1
Set StateTest.PLight OnWhileSteady true
Set StateTest.PLight TimeSteadyMaximum 5
Set StateTest.PLight TimeSteadyMinimum 1
Set StateTest.PLight TimesToFlickerMaximum 5
Set StateTest.PLight TimesToFlickerMinimum 1
Summon StateTest.PLight
The reason there's two summon calls is because the "Set"s won't work unless the class is in memory, so I summon it once to load it, then I set all the variables, then summon another one. Keep in mind this can't be done if bStatic or bNoDelete are true (which they are in the parent class "Light," which is why I set them to false in PLight).
It's strange to me that "3/10" never appeared in your log with your own code. When I executed your code, I saw it go from 3/10 to 10/10 repeatedly (since it kept looping back to "Begin").
How exactly are you testing the script?
Of all the things I've lost, I miss my mind the most.
-
.:..:
- OldUnreal Member
- Posts: 1637
- Joined: Tue Aug 16, 2005 4:35 am
Re: I'm stupid. (help with state syntax)
Since you extended your class on Light, did you change on DefaultProperties "bStatic=False"?
Also if you wrote this on Editor you might aswell forgot to compile scripts.
Also if you wrote this on Editor you might aswell forgot to compile scripts.
(ಠ_ಠ)1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD