ACM - Advanced Controls Mod [Besiege v0.45]

Lench

Active Member
#82
Update v1.5.0: Translation support
  • Supports translation files in json format.
    To create your own translation file, download the English template en-US.json and save it in
    directory Besiege_Data/Mods/Resources/AdvancedControls/ as <my-language>.json, for example de-de.json or german.json.
    Then, type `acm language german` to console to load it.
    To reset to default language, enter `acm language en-US`.

  • Add Vacuum block power control.
  • Fix bugs causing crashes on some OS X systems.
  • Fix axis and button names not being properly resolved from game controller database.
 

ikt

New Member
#83
Very nice! Sadly somehow it doesn't work as expected.

I'm using an Xbox 360 controller, and I assigned left trigger/right trigger to a combined Throttle control which works fine.

Then there are two sets of pistons that I want to control using the left thumb stick. Left direction works, right direction doesn't work. I tried creating the same piston and applying the same rules but it still doesn't work, it only works with the assigned keyboard key although the axis is registered for that block. I attached my vehicle with these controls. It seems to have saved correctly, because the advanced controls when loading up the model are still present. They just don't work :/

Edit -
Okay, it seems to work sometimes. After restarting Besiege several times and/or reloading the model a few times, the steering, throttle and camera all semi-work. Any reason why?

* No other applications using XInput seem to be running
* Controller works normally for other games. Wireless Xbox 360 controller. Same happens with wired.
* Besiege v0.42b with Spaar Mod Loader 1.6.2 and the latest version of this mod
* Game runs at 60FPS
* 122 block machine, all vanilla

Another edit -
Okay, seems like things/controls/overrides keep getting stuck between loads, for example between my non-ACM version and my ACM version.
 

Attachments

Last edited:

Lench

Active Member
#84
Very nice! Sadly somehow it doesn't work as expected.

I'm using an Xbox 360 controller, and I assigned left trigger/right trigger to a combined Throttle control which works fine.

Then there are two sets of pistons that I want to control using the left thumb stick. Left direction works, right direction doesn't work. I tried creating the same piston and applying the same rules but it still doesn't work, it only works with the assigned keyboard key although the axis is registered for that block. I attached my vehicle with these controls. It seems to have saved correctly, because the advanced controls when loading up the model are still present. They just don't work :/

Edit -
Okay, it seems to work sometimes. After restarting Besiege several times and/or reloading the model a few times, the steering, throttle and camera all semi-work. Any reason why?

* No other applications using XInput seem to be running
* Controller works normally for other games. Wireless Xbox 360 controller. Same happens with wired.
* Besiege v0.42b with Spaar Mod Loader 1.6.2 and the latest version of this mod
* Game runs at 60FPS
* 122 block machine, all vanilla

Another edit -
Okay, seems like things/controls/overrides keep getting stuck between loads, for example between my non-ACM version and my ACM version.
Thanks for your report. I'm aware of a problem with pistons. I'm working on a fix, but I'm really busy with other stuff. Should be up some time over the weekend.
 
#86
First off: I love this mod.
Now I have one question... There is an open source software called Betaflight which is used on multicopters to basically do math with control and gyro inputs in order to calculate the throttle values for the individual motors on the particular copter to have it do what you want and stay stable.
Would it be possible to pull movement data from for example the source block as a gyro and run betaflight over the values to then make the motor throttle values virtual control axes to return to your creation?
 

Lench

Active Member
#87
First off: I love this mod.
Now I have one question... There is an open source software called Betaflight which is used on multicopters to basically do math with control and gyro inputs in order to calculate the throttle values for the individual motors on the particular copter to have it do what you want and stay stable.
Would it be possible to pull movement data from for example the source block as a gyro and run betaflight over the values to then make the motor throttle values virtual control axes to return to your creation?
Yes. You could do it using custom axes.

ACM isn't the best tool for this though. Custom axes are not meant for this complex behaviors. I have used my scripting mod to do exactly this before and even wrote a tutorial for it. You can see it in action here.
Using the scripting mod will require some programming experience though.

The Python script runs a control feedback loop (PID controller) for pitch, roll and altitude that adjusts rotor throttle values to keep the drone in the desired position.
You can then integrate the script with ACM to fetch axis values, like I do in the video above.

If you're interested, you're welcome to join me on the besiege discord server and I'll help with whatever I can.
 
#88
Yes. You could do it using custom axes.

ACM isn't the best tool for this though. Custom axes are not meant for this complex behaviors. I have used my scripting mod to do exactly this before and even wrote a tutorial for it. You can see it in action here.
Using the scripting mod will require some programming experience though.

The Python script runs a control feedback loop (PID controller) for pitch, roll and altitude that adjusts rotor throttle values to keep the drone in the desired position.
You can then integrate the script with ACM to fetch axis values, like I do in the video above.

If you're interested, you're welcome to join me on the besiege discord server and I'll help with whatever I can.
Dayum, I honestly did not quite pay attention to your scripting mod yet. I am gonna try to mess around with that now I guess. You do a damn awesome job on your mods. Also thanks for your reply :D
 
#91
First of all, I love this mod, it makes steering so easy. I have two requests though:
1. Could you implement a arctan2 combination axis? I want to map the direction of my analog stick to a steering block (for example to control a turret in a top down view), but since it only outputs x and y values I'd have to use arctan2 to calculate the angle from that.
2. Could you implement a mouse axis that uses relative movement? The way it works now with values mapped to the screen isn't really useful. I would like to make my turret follow the mouse just like in any other game.
Thanks!
 

Lench

Active Member
#92
First of all, I love this mod, it makes steering so easy. I have two requests though:
1. Could you implement a arctan2 combination axis? I want to map the direction of my analog stick to a steering block (for example to control a turret in a top down view), but since it only outputs x and y values I'd have to use arctan2 to calculate the angle from that.
2. Could you implement a mouse axis that uses relative movement? The way it works now with values mapped to the screen isn't really useful. I would like to make my turret follow the mouse just like in any other game.
Thanks!
Both of these requests are already possible, but perhaps more complicated than you imagine.

For arctan2 combination axis (or any other mathematical function you can imagine), there is the custom axis. You can use it to get values from any number of axis (or even other data like block position, rotation, speed, mouse cursor raycast, some other raycast, ... ) by writing a mathematical expression in Python programming language, which is fairly simple. It would look something like this:

Init code:
Code:
import math
axis1 = AdvancedControls.GetAxis("some axis name")
axis2 = AdvancedControls.GetAxis("some other axis name")
Update code:
Code:
math.atan2(axis1.OutputValue, axis2.OutputValue)
As for the turret following the mouse, the mechanics are very complicated. Although it is possible to do it in ACM, I highly recommend using my scripting mod instead. It will require some programming knowledge though, as what you're asking for is very complicated and cannot be implemented as some sort of easy to use mod functionality.

First there is raycasting to get the 3d world coordinates of the mouse cursor. Then you subtract it from turret coordinates and calculate the angle that you need to turn your turret to. The turning itself is the most complicated as you will need to program some feedback control loops in order to be precise. Something like that can be seen on my turret here:

 
#93
I suspected atan2 would be possible with python, I have been shying away from learning a new programming language just for that though. So far I was able to do everything with combination axis and binary logic (even though you said not to make long chains of them, haha). Might give this a try.

I think you're overcomplicating (or overawesomeing) the mouse thing. I don't need the turret to follow the position of the mouse on the screen. I just need to get the movement speed of the mouse relative to the screen (even when it's on the edge of the screen, just like the regular camera controls in Besiege). Put a camera on the turret, then map a shooting block to LMB and a zoomed camera to RMB and bam, fps controls.
 
Last edited:

Lench

Active Member
#94
I suspected atan2 would be possible with python, I have been shying away from learning a new programming language though. So far I was able to do everything with combination axis and binary logic (even though you said not to make long chains of them, haha). Might give this a try.
I think you're overcomplicating (or overawesomeing) the mouse thing. I don't need the turret to follow the position of the mouse on the screen. I just need to get the movement speed of the mouse relative to itself (even when it's on the edge of the screen, just like the regular camera controls in Besiege). Put a camera on the turret, then map a shooting block to LMB and a zoomed camera to RMB and bam, fps controls.
Oh, FPS like controls, yeah that's much easier.

Just create a custom axis and put this into update code:
Code:
Input.GetAxis("Mouse X")
or ...

Code:
Input.GetAxis("Mouse Y")
 
Last edited:
#95
I tried the atan2 thing, but it only works within a 90° arc in the front. Everything else becomes 1 (right half) or -1 (left half). As if it mapped 1 to 45° and -1 to -45° and everything beyond ±45° gets capped.
Another strange thing: if both axis become 0, it also jumps to 1 or -1. I'd rather have it return to 0.
Update: atan2 outputs values in radians (±π) and we capped them to ±1, which is ±57°. So we need to divide by π.
Code:
math.atan2(axis1.OutputValue, axis2.OutputValue)/math.pi
 
#97
I made another axis that returns the radius of the same stick by pythagoras:
Code:
math.sqrt(axis1.OutputValue * axis1.OutputValue + axis2.OutputValue * axis2.OutputValue)
Probably not the prettiest code, but it works.
I mapped it to my wheel speed and mapped the atan2 axis to a 360° steering hinge on every wheel.
Now I got a whacky litte contraption that goes wherever I point my left stick, just like a hovercraft but without sliding like on ice. And I learned some python. Unfortunately the thing gets turned around by every bump, but I don't want to get into advanced scripting yet to fix that. Or do I?
 
Last edited:
Works like a charm, thanks. I suspect this will be a must have for multiplayer battles once multiverse comes out. Would be great if you could make that a standard controller axis in a future update, with a sensitivity slider etc.
I used my mouse driver to map LMB to "C" and another mouse button to LMB. Not ideal, but it works for me.
Do you know a way to switch to a zoomed camera block while a button or trigger is held down and switch back to the original camera block when released?
 
Top