-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Real-time engine tweaking via 👼Script - with example. #3177
Merged
ohlidalp
merged 12 commits into
RigsOfRods:master
from
ohlidalp:Gibzy_clutch_modif_keys
Jan 26, 2025
Merged
Real-time engine tweaking via 👼Script - with example. #3177
ohlidalp
merged 12 commits into
RigsOfRods:master
from
ohlidalp:Gibzy_clutch_modif_keys
Jan 26, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as outdated.
This comment was marked as outdated.
"Engine" is quite ambiguous (a render engine, a physics engine...) but "EngineSim" became synonymous with The Engine Simulator by AngeTheGreat https://www.engine-sim.parts/, so I'm reverting this old change of mine.
The gear-vector prep code was moved from ActorSpawner.cpp to Engine.cpp Engine.h codechanges: - added doxy comments about 'engine' keyword args - added `getDiffRatio()` getter so `m_diff_ratio` is no longer a dead attr - will be bound to AngelScript later
This touches many files but it's just find&replace of the renamed functions in Engine.h This is a preparation for AngelScript bindings which must all be `camelCase()`.
Deleted `Engine::shiftmodes`, using global `SimGearboxMode` (see Application.h) for everything. The enums are the same except for syntax.
tidy up of conf funcs, added diag funcs
Engine class upgraded to RefCountingObject - that means all codebase uses EnginePtr now. Ambiguous func `Engine::getEngineTorque()` renamed to `getCurEngineTorque()` Func `Engine::getShiftingToGear()` renamed to `getShifTargetGear()` Engine.h - some more doxygen doc shuffling.
To go with accel/brake modifiers. Suggested by Gibbzy on Discord: https://discord.com/channels/136544456244461568/189904947649708032/1280998672246771753
ohlidalp
force-pushed
the
Gibzy_clutch_modif_keys
branch
from
January 24, 2025 19:39
f20db9e
to
51656ae
Compare
How to read 'engine/engoption' attributes: Each value is displayed twice (for debugging) from different sources: 1. the 'get***' value is what EngineClass object reports via `get***()` functions. 2. the UPPERCASE value is what ActorClass object reports via `getSimAttribute()` function. There are exceptions, a few values have multiple EngineClass getters or lack Attribute handle.
ohlidalp
force-pushed
the
Gibzy_clutch_modif_keys
branch
from
January 25, 2025 00:49
51656ae
to
790cb00
Compare
ohlidalp
changed the title
Added
Real-time engine tweaking via 👼Script - with example.
Jan 25, 2025
EV_TRUCK_MANUAL_CLUTCH_MODIFIER_25/50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome script. One issue though:
Spawn the Pontiac Firebird and switch to neutral gear, results in a divide by zero error:
The script ended with exception; details below:
context.ExceptionLineNumber: 38
context.ExceptionString: Divide by zero
context.ExceptionFunction.Declaration: void updateEnginePlotBuffers(EngineClass@)
context.ExceptionFunction.ModuleName: example_actor_engineDiag.as(category:CUSTOM,unique ID:11)
context.ExceptionFunction.ScriptSectionName: example_actor_engineDiag.as
context.ExceptionFunction.ObjectName:
I've renamed confusing EngineClass attr getters:
The 'example_actor_engineDiag.as' was updated:
|
Changes: * `getMaxRPM()` --> `getShiftDownRPM()` -- equivalent of `ACTORSIMATTR_ENGINE_SHIFT_DOWN_RPM` * `getMinRPM()` --> `getShiftUpRPM()` -- equivalent of `ACTORSIMATTR_ENGINE_SHIFT_UP_RPM` The 'example_actor_engineDiag.as' was updated: * updated 'engine' tab to show new names * completely removed the 'clutch' tab as it didn't make sense anymore - I got confused by the min/max RPM when writing it. This also fixes a division-by-zero script crash reported by Mike. * fixed plot min/max values in the 'state' tab.
// Attributes can be edited realtime (on every keystroke) or using the [Focus] button. // Focused editing means all other inputs are disabled and [Apply/Reset] buttons must be used. ^ This hint was added to the help box.
ohlidalp
force-pushed
the
Gibzy_clutch_modif_keys
branch
from
January 25, 2025 15:18
93f6c37
to
720b275
Compare
CuriousMike56
approved these changes
Jan 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added input events
EV_TRUCK_MANUAL_CLUTCH_MODIFIER_25/50
To go with existing accel/brake modifiers. Suggested by Gibbzy on Discord: https://discord.com/channels/136544456244461568/189904947649708032/1280998672246771753UPDATE: Turns out this needs more research - the modifiers work but they don't have the desired effect, see Discussion: https://discord.com/channels/136544456244461568/189904947649708032/1282776986107773010. To research further, I've dusted off my Engine-AngelScript bindings (made a year ago and never merged) and created an engine diagnostic script 📜 'example_actor_engineDiag.as'.
UPDATE2: To help modders figure out what the engine needs, I've extended the above script with real-time engine tweaking capabilities. This is possible thanks to the
ACTORSIMATTR_
system introduced recently in #3210. 'engturbo' isn't in the tool yet but the ACTORSIMATTR_ constants exist.Either way it's just an example script, if anybody finds it almost useful let me know.