Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
You don't need to read it with LUA. You just need to read the composite data. There's logic blocks for that in the microcontroller editor.
A brief tutorial
Composite data has 2 simultaneous sides: on/off data and number data. You can send and receive both on the same composite data line.
The radar works by sending you an on/off for if a target has been found. It can detect up to 8 targets. The channel number on the composite data is which target it is. The first target detected is channel 1. The 2nd is channel 2 and so on.
Radar uses the number side of the comp data to give you I for on the target. It does this in chunks of 4. So the first target takes channels 1,2,3, and 4. The 2nd takes 5-8, and so on. The data is formated like this (if I remember right. The comp output on Radar explains it):
1. Distance between radar and target
2. Azimuth
3. Elevation
4. Time since detection
So to make a simple turret, you just need to use a composite read to check channel 1 on the on/off data. If it's on, then read channel 2 and channel 3 from the numeric data. Channel 2 (the Azimuth) tells your turret where to turn to. Channel (the elevation) tells your turret how to pitch itself (aim vertically). You then send those channels out of the MC to the horizontal and vertical pivots of your turret. You might need to multiply or invert the values depending on how you design your turret, but you don't need to use any LUA for a basic turret.
I'll take a look at what I have so far from the other tutorial and see if I can understand some of it. Thank you. Ive just been following the tutorials without really understanding what its doing.
By the way, am I the last one who plays stormwors for saving people, not killing them?
and how to insert this info in LUA?, trying to make a radar display here, but man, this is hard for someone who only did a "hello world" in university.
Here's an example, that takes in a composite radar info and output 8 (x,y) co-ordinates on composite channels 17-32 co-ordinates output are relative to the radar, so to convert to world co-ordinates you would need the position of the radar and its pitch and roll:
positions = {}
MapDist = 0
-- Tick function that will be executed every logic tick
function onTick()
for i = 0,7,1 do
if input.getBool(i + 1) then
MapDist = input.getNumber(4*i +1)*math.cos(input.getNumber(4*i +3)*2*math.pi)
positions[2*i+1] = MapDist*math.sin(input.getNumber(4*i +2)*2*math.pi)
positions[2*i+2] = MapDist*math.cos(input.getNumber(4*i +2)*2*math.pi)
else
positions[2*i+1] = 0
positions[2*i+2] = 0
end
end
for i=1,16,1 do
output.setNumber(16+i,positions[i])
end
end
But, i understand pretty well your code, (except the part where you asing the values to "i"), and help me to understand a bit more the code. Tnxs
This is just the syntax that Lua takes on a for loop, so that means run an iteration over a variable i which goes from 0 to 7 and increments by 1 each time. So its i={first},{last},{increment}
https://www.lua.org/pil/4.3.4.html