The Android app I'm using is called MATRIC, it also has an API so I made an interface to take Stormworks data and send it over to MATRIC.
I'm sure you can all think of better ways to utilize this information. Sending it over to MATRIC can limit how you display the data but it's the only way to really do it if you want to use the tablet as an input device and not develop your own app.
The simplest method is absolutely to do it in a Lua block. It's possible to do it with a bunch of numeric switches (symbol looks kind of like >
) and less-than blocks (symbol is <
), but that takes a ton of space and wiring.
The Lua editor in-game isn't great; you can't see if your code works without building/launching the entire vehicle. Recommend copying out the function signatures into an external editor and doing your development there. You can install Lua locally, or you can use an online editor like https://repl.it/languages/lua.
Ok so what I would recommend you do is use a lua table. A lua table is a lot like a big list of variables. If you want to keep it simple, use a table as an array where each variable stored inside of it can be accessed via an index or number. Sorry if I’m not good at explaining this so you might want to consider looking at this
https://www.lua.org/pil/11.1.html
You could have 2 arrays, one called x and one called y. This is how you would initialize it:
x = {} y = {}
If you for example wanted to add an object at the point (2,3) to these arrays you could say:
x[1] = 2 y[1] = 3
Notice that the “1” means that I am storing those numbers to the first index of the array. To store another object I would use “2” the next time around.
Of course you wouldn’t actually use 1 or 2 to select the index but you should instead use a variable, that way you can simply add one to that variable to select a new index to store to.
For reading an array, you can use a for loop to access each x y value within and place a pixel/dot for each of those.
Again, if you haven’t heard of this I’m sure you might want to google more about arrays in programming.
Another option you could have would be to store objects in a completely different way using their angle as the index for an array, and the value at that index is its distance from the origin. For this you would only have one array, let’s call it r meaning the radial distance from the origin:
r = {}
Then every tick you could say
r[a] = the distance of the object
Where a is the angle of the sensor.
The advantage to this method is that it will automatically overwrite previous objects that were previously at that same angle the revolution before. The disadvantage is that you still need to compute the trig (cos and sin) in order to get the x y values for the pixels.
Sorry if this was very long. Please do ask more questions because I would imagine you would have some.
would this be good? this