RPMDelta not working?

General discussion about RailWorks, your thoughts, questions, news and views!

Moderator: Moderators

Locked
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

RPMDelta not working?

Post by sanyix »

function Update (time)
rpm_change = Call( "*:GetControlValue", "RPMDelta", 0 )
if ( rpm_change > 0.001 ) then
Call("M62surge:SetEmitterActive",1);
--else
--Call("M62surge:SetEmitterActive",0);
end
end

But but the rpmdelta never activates the emitter, while in same time with same call the engine start activates the emitter.
On control value dialog i see that the rpmdelta changing but still not activates the emitter.

I really have no idea why.
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
User avatar
karma99
Very Active Forum Member
Posts: 2329
Joined: Wed Oct 17, 2007 8:21 pm
Location: Portsmouth, UK

Re: RPMDelta not working?

Post by karma99 »

sanyix wrote:function Update (time)
rpm_change = Call( "*:GetControlValue", "RPMDelta", 0 )
if ( rpm_change > 0.001 ) then
Call("M62surge:SetEmitterActive",1);
--else
--Call("M62surge:SetEmitterActive",0);
end
end

But but the rpmdelta never activates the emitter, while in same time with same call the engine start activates the emitter.
On control value dialog i see that the rpmdelta changing but still not activates the emitter.

I really have no idea why.

Pretty sure you need to lose the brackets around the if
I did the EXACT same thing 2 days ago... switching the brain from daytime C# to night time lua is a constant pain!

if rpm_change > 0.001 then
Call("M62surge:SetEmitterActive",1);
--else
--Call("M62surge:SetEmitterActive",0);
end
Image
Links: Shop <> Blog <> Facebook
scefhwil
Well Established Forum Member
Posts: 907
Joined: Tue Dec 04, 2001 12:00 am
Location: Bristol, England

Re: RPMDelta not working?

Post by scefhwil »

From my playing around with lua scripts I recon that GetControlValue only has access to controls that are defined in the engine blueprint. RPMDelta seems to be an audio system only control that is only accessible to audio control blueprints.

To do what you want you will have to create your own rpmdelta using Call( "*:GetControlValue", "RPM", 0 ) and comparing old to new values over the time interval.

Stuart
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

Re: RPMDelta not working?

Post by sanyix »

Rpmdelta is working in scripts, just the rw lua compiler have very strange behaviors. I did some emitter changes in oncontrolvaluechange function. And other ones in update function. The funny is, i you don't call beginupdate in initialise, then the update wont update. But if you do then in oncontrolvaluechange you wont be able to manipulate the emitters (simply the code there stops working).

And other strange thing:

regulator= Call( "*:GetControlValue", "Regulator", 0 )
delta= Call( "*:GetControlValue", "RPMDelta", 0 )
engsta= Call( "*:GetControlValue", "EngineStart",0)
if ((delta > 0) or ((0.1<engsta) and (engsta<0.9))) then
Call("M62surge:SetEmitterActive",1);
else
Call("M62surge:SetEmitterActive",0);
end

this is working correctly

if i change the if statement to if ((delta > 0) or (0.1<engsta<0.9)) the luac parser says ok.
But this if will be always true if once the delta > 0 (even if it isn't), and in same time the enginestart isn't changed.
But if i seperate the ifs to:
if ((delta > 0)....
end
if (0.1<engsta<0.9) ....
end
then the second if will be always FALSE, and the luac parser says OK again

After this i've used that statement above, but STILL didn't worked, when the luac parser said the syntax is correct. Then suddenly after some retries it worked...

BTW where is the documentation of the setemitter calls from the rw wiki? :D (i've read this in another script) maybe rw have a lots of good things, but noone knows about it because it's undocumented...
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

Re: RPMDelta not working?

Post by sanyix »

karma99 wrote:Pretty sure you need to lose the brackets around the if
I did the EXACT same thing 2 days ago... switching the brain from daytime C# to night time lua is a constant pain!
same here, but i'm JAVA programmer :)
Those brackets can make issues like this? That would be funny since i've never seen such issues in pascal, java, c#, js or php.
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

Re: RPMDelta not working?

Post by sanyix »

Is there any usermade lua callable thing reference for rw? The rswiki "reference" is very incomplete...
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
User avatar
AndiS
Very Active Forum Member
Posts: 6207
Joined: Fri Sep 23, 2005 4:43 pm
Location: Jester's cell in ivory tower
Contact:

Re: RPMDelta not working?

Post by AndiS »

No reference here either.

But I would put all the GetControlValue into OnControlValueChange -- in doubt.

I am pretty sure that the () are not the real problem. But some place in the documentation says that you need double parentheses for the Print call, and I vaguely remember having a problem with this call and only one layer of parentheses. So I don't make any assumptions about the RW implementation of Lua any more.

And I would not waste time with (0.1<engsta<0.9) but stick with (0.1<engsta) and (engsta<0.9), just to make life simpler.
davveb
Established Forum Member
Posts: 406
Joined: Thu Oct 23, 2008 5:17 pm

Re: RPMDelta not working?

Post by davveb »

RPMDelta works fine in RailWorks script. I can't remember how off the top of my head, and I'm not on my gaming computer at the moment, but have a look at the scripts for the RW GP7 or the HST update I did. I used RPM_Delta to trigger the exhaust "surge".
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

Re: RPMDelta not working?

Post by sanyix »

if name=="RPM" then
if ((50<value) and (value<350)) then

please someone tell me, me how can the 2nd if can be true, from 1 rpm to infinty, but not from 400 rpm to 0rpm?
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
User avatar
AndiS
Very Active Forum Member
Posts: 6207
Joined: Fri Sep 23, 2005 4:43 pm
Location: Jester's cell in ivory tower
Contact:

Re: RPMDelta not working?

Post by AndiS »

In my view, it would be true for just above 50 to just below 350, not 0, not 400, etc.

Must likely, something in another place of the script went wrong, if you see something happening with 400 rpm.

The above case is one where you can perfectly go without all the (). I said that I don't think they harm, but I also say that I don't make any permanent assumptions any more. But I have no idea how parentheses can make this statement to evaluate to true for some other range of values.
sanyix
Been on the forums for a while
Posts: 232
Joined: Wed Mar 03, 2010 7:24 pm

Re: RPMDelta not working?

Post by sanyix »

AndiS wrote:In my view, it would be true for just above 50 to just below 350, not 0, not 400, etc.

Must likely, something in another place of the script went wrong, if you see something happening with 400 rpm.
Yes that would be the correct but not that happens. The value and name directly taken from OnControlValueChange.

The strangest thing, this activated just when the rpm is rising, and never when falling.
Maybe the lua is working with not real numbers, but numbers from the 5. dimension? :))
Or just the OnControlValueChange event is bugged in rw, and not working as it should.

Anyway i can't even debug it, because if i set the logmate filter to "all", the game freezes after some seconds when the log spam comes, and the "Script Manager" filter doesn't work.
My top wishes: Realistic engine physics - Superelevation - Multi-core support - Remove Physix engine, and use better one
Locked

Return to “[RW] General RW Discussion”