Skip to content
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

👼Script: get/set ActorSimAttr directly - HAZARDOUS ⚠️ #3210

Merged

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Jan 10, 2025

Allows advanced users to set actor physics attributes directly, including some not accessible from .truck file format.

In AngelScript, the actor (BeamClass) got 2 new methods:

    void setSimAttribute(ActorSimAttr attr, float val);
    float getSimAttribute(ActorSimAttr attr);

The set* function always logs "[RoR|Actor] setSimAttribute: '{attr}' = {val}", where {attr} is the attribute name as string.

Currently, the available attributes only cover TractionControl:

    ACTORSIMATTR_TC_RATIO, //!< Regulating force, safe values: <1 - 20>
    ACTORSIMATTR_TC_PULSE_TIME, //!< Pulse duration in seconds, safe values <0.00005 - 1>
    ACTORSIMATTR_TC_WHEELSLIP_CONSTANT //!< Minimum wheel slip threshold, safe value = 0.25

Fixes #3188 - The wheel slip constant was hardcoded since 57dfbba but now it's adjustable again. Note that this is possibly not the final solution and other wheelslip coefs may need to be added, i.e. ACTORSIMATTR_TC_WHEELSLIP_CURSPEED_RATIO which would emulate the way it worked in earlier versions. This is open for experimenting.

Tip: To set this value automatically on each spawn, you can attach a script via .truck file format, see #3001 and enter this code:

void main() { thisActor.setSimAttribute(ACTORSIMATTR_TC_WHEELSLIP_CONSTANT, 0.2); }

Scripting reference manual is at https://developer.rigsofrods.org/d2/d42/group___script_side_a_p_is.html though it applies to previous stable release

Allows advanced users to set physics settings directly, including some not accessible from rig-def file format.

In AngelScript, the actor (BeamClass) got 2 new methods:
```
    void setSimAttribute(ActorSimAttr attr, float val);
    float getSimAttribute(ActorSimAttr attr);
```
The set* function always logs _"[RoR|Actor] setSimAttribute: '{attr}' = {val}"_, where {attr} is the attribute name as string.

Currently, the available attributes only cover TractionControl:
```
    ACTORSIMATTR_TC_RATIO, //!< Regulating force, safe values: <1 - 20>
    ACTORSIMATTR_TC_PULSE_TIME, //!< Pulse duration in seconds, safe values <0.00005 - 1>
    ACTORSIMATTR_TC_WHEELSLIP_CONSTANT //!< Minimum wheel slip threshold, safe value = 0.25
```

Fixes RigsOfRods#3188 - The wheel slip constant was hardcoded since 57dfbba but now it's adjustable again. Note that this is possibly not the final solution and other wheelslip coefs may need to be added, i.e. ACTORSIMATTR_TC_WHEELSLIP_CURSPEED_RATIO which would emulate the way it worked in earlier versions. This is open for experimenting.
@CuriousMike56
Copy link
Member

Works nicely 👍

@ohlidalp ohlidalp merged commit a6ad204 into RigsOfRods:master Jan 11, 2025
2 checks passed
@ohlidalp ohlidalp deleted the 3188_Whitespacerebel_tractioncontrol_slip branch January 12, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Traction Control Improvement
2 participants