Unit Logic Course #2 | How to use Flags + How they work

Поділитися
Вставка
  • Опубліковано 27 вер 2024
  • #Mindustry
    #Logic
    Music: Scheming Weasel - Kevin MacLeod

КОМЕНТАРІ • 88

  • @ekappaz504
    @ekappaz504 3 роки тому +46

    Now I can bind to specific flares and not steal every single flare on the map

    • @ElectricGun100
      @ElectricGun100  3 роки тому +15

      All processors must have a flag rule

    • @brlinrainf
      @brlinrainf Місяць тому

      I can bind only a few amount of units by repeating bind and set variable a few times, so when a unit control code is needed to run it will just bind to the unit in variable. the other processors might still conflict but uhhh whatever i could do the same or whatever

  • @6Twisted
    @6Twisted 3 роки тому +20

    I despise Mindustry logic. I'm used to programming using Ifs and loops and having to use jumps quickly turns any program into a hard to follow mess.

    • @ElectricGun100
      @ElectricGun100  3 роки тому +10

      Same

    • @zinobi
      @zinobi 3 роки тому +7

      I occasionally do assembly programming so I'm used to only having jumps, but a lot of programming in mindustry feels like being back in the early 90s.

    • @joshuadavis5899
      @joshuadavis5899 Рік тому +2

      I think it's meant to be kinda unwieldy so that you stay within the game and don't go into full programmer mode

    • @fabiulaviana56
      @fabiulaviana56 4 місяці тому +2

      ​@@ElectricGun100 Even worse if you aren't a programmer like me just trying to get Meta glass from kilns to the core with 2 micro processors...

  • @fodk7021
    @fodk7021 3 роки тому +14

    Thanks to this tutorial I made a turret feeder. Thank you so much. The turret feeder is on my channel by the way not promoting just for those who may want the schematic

  • @shreyasdas5130
    @shreyasdas5130 3 роки тому +18

    This is a highly useful method, semaphore, used wildly in any os to avoid the fetch of stale data or to have two writers modify the same file at once. It is used in real life and yes!! Also in your current device.

  • @No-jz1jk
    @No-jz1jk 3 роки тому +13

    In theory you could use units to transfer info over long distances

    • @ElectricGun100
      @ElectricGun100  3 роки тому +9

      That's literally a thing ever since logic came out

    • @LoerisOtter
      @LoerisOtter 2 роки тому

      How do you transfer info in units?
      Store the info in the flag?

    • @ScorpioneOrzion
      @ScorpioneOrzion 2 роки тому

      @@LoerisOtter basically

  • @rushiewashie
    @rushiewashie 3 роки тому +8

    We finally know what the magic numbers mean now

  • @SF-zm2py
    @SF-zm2py Рік тому +2

    My only complaint is that there's no write lock. For the uninformed, a write lock would prevent two processors from reading an empty flag and trying to write a new flag simultaneously, which could lead to a single flag value, but multiple controlling processors. However, that's only really a problem because the two processors are trying to spam bind units. My typical work around to stay at a separate processor handle requests from the two originals.

    • @ElectricGun100
      @ElectricGun100  Рік тому +1

      Honestly, I don't see that as a problem as, typically, the processors would check for the flag number a second time and skip or bind that particular unit based on its number. It might cause some hiccups in the unit for a few seconds, but it should be fine in the long run.

  • @Kaisenburb
    @Kaisenburb Рік тому +2

    It doesn't work when you change the flag value they still stick to processor 4:00

  • @dylanherrera5395
    @dylanherrera5395 6 місяців тому +1

    basically:
    the proccesor went "thats my unit >:(" and put a mark on the unit telling the other processors that its his
    sounds an awful lot like a slave mark to me

  • @saro9359
    @saro9359 Рік тому +2

    thats nice and all but you didn't explain one thing
    how can I bind a certain amount on each processor ?

  • @dementedsoap7880
    @dementedsoap7880 10 місяців тому +1

    how do I check how many units are bound, for example I want 2 processors to control 2 flares each, and only 2 flares each and leave the rest idle.

  • @noahbluecoat
    @noahbluecoat 2 роки тому +2

    I tried the tutorial even though it was released last year. It is not working for me sadly. So I'm trying to figure out what's the problem since thisx and thisy keeps on sending the units bottom left corner of the map.

    • @diakounknown1225
      @diakounknown1225 Рік тому

      I know it's been two months, but @thisx and @thisy

  • @4ehoBek_4ehoBek
    @4ehoBek_4ehoBek 2 роки тому +2

    This is the answer why my flare delivery working bad

  • @nyscersul42
    @nyscersul42 Рік тому +6

    For anyone coming here to learn... this is a great tutorial that explains how most people do the job, and, it explains well. The following is a discussion point for advanced logic users only. :)
    Firstly, i love that bit of music hehehe
    Secondly... Flagging isnt as necesary as people think that it is. I have several campaign bases which run a variety of unit based processors. And, they all run without conflicts, and, no flags. This leaves me capable of using the flagging system for higher level control, such as allowing processors to request a taxi for units which are not capable of flying, and to encode the target location into the flag. I even have some systems which are set up to display collective information about all of the units, as i figured out also how to bind a unit and read it's sensor data without ever confusing it's registered controller variable, allowing access to that data without disturbing the unit's job. I used it to create two displays, one which shows how many units of each type exist, and, how many are idle, and a second one which displays a sort of behavioural heatmap, showing every unit as a new dot and the dot's colour is defined by the activity. Then, it fades the display.

    • @nyscersul42
      @nyscersul42 Рік тому +5

      Oh, also, i should mention that for any unit controller which doesnt try to take control of every unit of a type then it's naturally compatible with my code. All the processor needs to do to "acquire" sole control to a unit is give it an order. It still doesnt conflict if the units are all taken, but, it does then fail to find free units of that type... So, my code naturally avoids conflicts with almost all other code. And not a single flag present to wave. If the other processors do use flags, it still doesnt conflict.

    • @nyscersul42
      @nyscersul42 Рік тому +5

      Another bonus to my non flagging system is that they dont actually require any code edits to make them work independently of each other, no need to allocate flags manually.

  • @gruuve
    @gruuve 3 роки тому +6

    Very nice video but only 480p (it was hard to see the text)

  • @SFraxure
    @SFraxure Рік тому +1

    This is a game changer

  • @PhaseArray
    @PhaseArray 3 роки тому +3

    I use flags on most of my unit logic

  • @uylol27
    @uylol27 Рік тому

    It stops working after i bind 2 flares :c

  • @premium_edits
    @premium_edits 2 роки тому

    bro u r a time saver 🛐 also subbed 👁️👄👁️

  • @diamondjitterz
    @diamondjitterz 2 роки тому +2

    This, Is Legendary, 10/10

  • @borzafror
    @borzafror Рік тому

    great tutorial

  • @sugarasphalt2008
    @sugarasphalt2008 3 роки тому +2

    Ok

  • @humanoidx977
    @humanoidx977 3 роки тому +1

    Thanks♥♥♥

  • @yeetdabeans3883
    @yeetdabeans3883 3 роки тому

    How do i flag only one unit

    • @ElectricGun100
      @ElectricGun100  3 роки тому +1

      Counters n stuff

    • @yeetdabeans3883
      @yeetdabeans3883 3 роки тому

      Wait nvm i just haven't watched the previous video

    • @Jay-iq4rp
      @Jay-iq4rp 3 роки тому

      @@ElectricGun100 i am trying to make a program that has a single mega move titanium from one container to another. How do I make the processor flag a single mega?

    • @ElectricGun100
      @ElectricGun100  3 роки тому +1

      @@Jay-iq4rp if @unit not null, stop binding

  • @yellomonke5080
    @yellomonke5080 3 роки тому +1

    The video is too fast i cant catch up shit

  • @MinhLe-nh1wq
    @MinhLe-nh1wq 2 роки тому

    i don’t want to be mean but its confusing

    • @ElectricGun100
      @ElectricGun100  2 роки тому

      I know right

    • @MinhLe-nh1wq
      @MinhLe-nh1wq 2 роки тому

      @@ElectricGun100 especially to a vietnamese guy like me, i can barely understand :(

  • @Makk_0
    @Makk_0 Рік тому +2

    Noob question:
    Isn't it possible to replicate the same effect of:
    jump 2 equal fl 0
    (Checks if the unit's flag is 0, flags the unit if it is, continues to the next if else statement if it isn't )
    jump 3 notEqual fl flag
    (Checks if the unit's flag is the flag set by this script, ends the command if it isn't, flags the unit again if it is, somehow)
    ucontrol flag flag 0 0 0 0
    end
    Just with:
    jump 2 notEqual fl 0
    (Checks if the unit's flag is not 0, ends the command if it isn't, flags the unit if it is)
    ucontrol flag flag 0 0 0 0
    end
    ?
    I did some testing here and it seems to work just fine for less commands.

    • @ElectricGun100
      @ElectricGun100  Рік тому +2

      The second jump exists to avoid flagging already flagged units

    • @Makk_0
      @Makk_0 Рік тому

      @@ElectricGun100 I know. I was asking if jump _ notEqual fl 0 is able to replicate the effect of "jump _ Equal fl 0" and "jump _ notEqual fl flag", since it prevents already flagged units from being flagged with this script's flag (ends the command if the unit's flag isn't 0, meaning that it doesn't flag any unit whose flag isn't 0), and allows flag-free units to be flagged (else, flags the unit with this script's flag, meaning that that it only flags units whose flag is 0). Maybe there's something more complex about it I didn't understand, but Idk.

  • @mopsbackupaccount5128
    @mopsbackupaccount5128 3 роки тому +3

    Ok

  • @VladisS.Vostok2000
    @VladisS.Vostok2000 3 роки тому +4

    If there is 2 processors with flare logic, first one will reserve all the flares settig flag by his own.
    How can i use one flare to each processor, including flare death case?

    • @ElectricGun100
      @ElectricGun100  3 роки тому +1

      Give each processor a unique flag and use a boolean that becomes 1 if a free flare is bound and flagged. Leave boolean as 0 if bound flare is already flagged

    • @VladisS.Vostok2000
      @VladisS.Vostok2000 3 роки тому +1

      @@ElectricGun100 Nice, but how can i be sure, that flare is dead?
      @unit doesnt become null when unit dead.

    • @ElectricGun100
      @ElectricGun100  3 роки тому +2

      @@VladisS.Vostok2000 @dead

  • @darkpaxgaming
    @darkpaxgaming 3 роки тому +3

    How to bind multiple unit types? Like flate and horizon? Thankyou

    • @darkpaxgaming
      @darkpaxgaming 3 роки тому

      Nvm. I found a way not very compact but possible. I use another processor with same full code i used but with different untit to bind because multiple bind commands dont go. So use only one bind that works

    • @ElectricGun100
      @ElectricGun100  3 роки тому

      You can use an array of unit binds on one processor then loop your entire code x number of times

    • @ElectricGun100
      @ElectricGun100  3 роки тому

      You cannot have more than one different unit binds during one CYCLE.
      TL;DR, you can bind different units on a single processor but it won't be efficient.

  • @Eric-se7ro
    @Eric-se7ro 2 роки тому +1

    what is logic schem code

  • @iwansugiartono9839
    @iwansugiartono9839 Рік тому

    Instruction unclear my small brain still didn't understand

  • @shtwick
    @shtwick Рік тому +1

    how do i put different flags on each individual mono, in order for them to do different tasks?

    • @pavlepetrovic989
      @pavlepetrovic989 Рік тому +1

      Have you figured it out? I've been searching and searching and searching, but i still have no clue

    • @shtwick
      @shtwick Рік тому

      @@pavlepetrovic989 i did

    • @shtwick
      @shtwick Рік тому

      @@pavlepetrovic989 actually nvm i dont

    • @pavlepetrovic989
      @pavlepetrovic989 Рік тому

      @@shtwick XD

    • @pavlepetrovic989
      @pavlepetrovic989 Рік тому

      @@shtwick did you just stop playing mindustry?

  • @kinghosty
    @kinghosty 2 роки тому

    not working