Welcome Back! Please login below. If you are not yet a member, why not register? Enjoy!
We have now opened a new Build server! IP: 188.165.193.102:27016

    Radio-based Message Transmitting [E2]

    Share
    avatar
    Blizzard
    Wire Pro
    Wire Pro

    Number of posts : 334
    Age : 26
    Location : Switzerland
    In-Game Name : [BS] Blizzard

    Credits Credits :
    1 / 1001 / 100

    Warnings! Warnings! :
    0 / 100 / 10

    Registration date : 2008-11-23
    Points : 342
    Reputation : 14
    20090927

    Radio-based Message Transmitting [E2]

    Post by Blizzard



    Longino wanted to me to make for him an E2, which is able to convert text (max. 32 characters) into numbers, to be able to push it through a radio system, since you're only able to send numbers via radios.
    In the end the radio addon was doing weird stuff, so we decided to put it ad acta and enjoy that we made a PoC (Proof of Concept) of processing text through it.
    We decided to put it on the forums, so you can try to do it if you like. And the most important thing, it may help you in coding with E2.
    I hope it's useful for you.
    The code itself is written pretty clean with some comments.

    Transmitting Module E2:
    Code:
    @name Transmitter Unit [Blizztech inside]
    @inputs Transmit String:string
    @outputs On Watt BaseMhz
    @outputs C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30 C31 C32
    @outputs Run Message:string Receiver:entity Sender:entity Index Count Array:array Dist Index2
    @trigger all
    #by Blizzard
    #find receiver
    if(findCanQuery()) {findByClass("ra_large_omni")
        Array = findToArray()
        Count = Array:count()
    }
    while(Index < Count & (Receiver == noentity() | Sender == noentity())) {
        Index++
        if(Array[Index,entity]:getColor() == vec(255,0,0)) {
            Receiver = Array[Index,entity]
        }
        if(Array[Index,entity]:getColor() == vec(0,255,0)) {
            Sender = Array[Index,entity]
        }
    if(Index >= Count) {Index = 0}
    }
    #calculate distance, set watts, split message
    Dist = Sender:pos():distance(Receiver:pos())
    Watt = Dist * 0.5
    if(Transmit & String:length() <= 32) {Run = 1
        Index2 = 0}
    if(Run == 1) {
        Message = String
        while(Index2 < Message:length()) {
        Index2++
            if(Index2 == 1)  {C1 = toByte(Message,Index2)}
            if(Index2 == 2)  {C2 = toByte(Message,Index2)}
            if(Index2 == 3)  {C3 = toByte(Message,Index2)}
            if(Index2 == 4)  {C4 = toByte(Message,Index2)}
            if(Index2 == 5)  {C5 = toByte(Message,Index2)}
            if(Index2 == 6)  {C6 = toByte(Message,Index2)}
            if(Index2 == 7)  {C7 = toByte(Message,Index2)}
            if(Index2 == 8)  {C8 = toByte(Message,Index2)}
            if(Index2 == 9)  {C9 = toByte(Message,Index2)}
            if(Index2 == 10) {C10 = toByte(Message,Index2)}
            if(Index2 == 11) {C11 = toByte(Message,Index2)}
            if(Index2 == 12) {C12 = toByte(Message,Index2)}
            if(Index2 == 13) {C13 = toByte(Message,Index2)}
            if(Index2 == 14) {C14 = toByte(Message,Index2)}
            if(Index2 == 15) {C15 = toByte(Message,Index2)}
            if(Index2 == 16) {C16 = toByte(Message,Index2)}
            if(Index2 == 17) {C17 = toByte(Message,Index2)}
            if(Index2 == 18) {C18 = toByte(Message,Index2)}
            if(Index2 == 19) {C19 = toByte(Message,Index2)}
            if(Index2 == 20) {C20 = toByte(Message,Index2)}
            if(Index2 == 21) {C21 = toByte(Message,Index2)}
            if(Index2 == 22) {C22 = toByte(Message,Index2)}
            if(Index2 == 23) {C23 = toByte(Message,Index2)}
            if(Index2 == 24) {C24 = toByte(Message,Index2)}
            if(Index2 == 25) {C25 = toByte(Message,Index2)}
            if(Index2 == 26) {C26 = toByte(Message,Index2)}
            if(Index2 == 27) {C27 = toByte(Message,Index2)}
            if(Index2 == 28) {C28 = toByte(Message,Index2)}
            if(Index2 == 29) {C29 = toByte(Message,Index2)}
            if(Index2 == 30) {C30 = toByte(Message,Index2)}
            if(Index2 == 31) {C31 = toByte(Message,Index2)}
            if(Index2 == 32) {C32 = toByte(Message,Index2)}
        }
    BaseMhz = 0
    timer("Mhz",100)
    Run = 0
    }
    if(clk("Mhz")) {
        BaseMhz = 2417
        On = 1
        timer("delay",5000)
    }
    if(clk("delay")) {
        On = 0
        C1 = 0
        C2 = 0
        C3 = 0
        C4 = 0
        C5 = 0
        C6 = 0
        C7 = 0
        C8 = 0
        C9 = 0
        C10 = 0
        C11 = 0
        C12 = 0
        C13 = 0
        C14 = 0
        C15 = 0
        C16 = 0
        C17 = 0
        C18 = 0
        C19 = 0
        C20 = 0
        C21 = 0
        C22 = 0
        C23 = 0
        C24 = 0
        C25 = 0
        C26 = 0
        C27 = 0
        C28 = 0
        C29 = 0
        C30 = 0
        C31 = 0
        C32 = 0
    }

    Receiving Unit E2:
    Code:
    @name Receiver Module [Blizztech Inside]
    @inputs Scr:wirelink C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30 C31 C32
    @outputs
    @outputs Message:string Ch1:string Ch2:string Ch3:string Ch4:string Ch5:string Ch6:string Ch7:string Ch8:string Ch9:string Ch10:string Ch11:string Ch12:string Ch13:string Ch14:string Ch15:string Ch16:string Ch17:string Ch18:string Ch19:string Ch20:string Ch21:string Ch22:string Ch23:string Ch24:string Ch25:string Ch26:string Ch27:string Ch28:string Ch29:string Ch30:string Ch31:string Ch32:string
    @trigger all
    #by Blizzard
    if(changed(C1)) {
    Ch1 = toChar(C1)
    Ch2 = toChar(C2)
    Ch3 = toChar(C3)
    Ch4 = toChar(C4)
    Ch5 = toChar(C5)
    Ch6 = toChar(C6)
    Ch7 = toChar(C7)
    Ch8 = toChar(C8)
    Ch9 = toChar(C9)
    Ch10 = toChar(C10)
    Ch11 = toChar(C11)
    Ch12 = toChar(C12)
    Ch13 = toChar(C13)
    Ch14 = toChar(C14)
    Ch15 = toChar(C15)
    Ch16 = toChar(C16)
    Ch17 = toChar(C17)
    Ch18 = toChar(C18)
    Ch19 = toChar(C19)
    Ch20 = toChar(C20)
    Ch21 = toChar(C21)
    Ch22 = toChar(C22)
    Ch23 = toChar(C23)
    Ch24 = toChar(C24)
    Ch25 = toChar(C25)
    Ch26 = toChar(C26)
    Ch27 = toChar(C27)
    Ch28 = toChar(C28)
    Ch29 = toChar(C29)
    Ch30 = toChar(C30)
    Ch31 = toChar(C31)
    Ch32 = toChar(C32)
    Message = Ch1+Ch2+Ch3+Ch4+Ch5+Ch6+Ch7+Ch8+Ch9+Ch10+Ch11+Ch12+Ch13+Ch14+Ch15+Ch16+Ch17+Ch18+Ch19+Ch20+Ch21+Ch22+Ch23+Ch24+Ch25+Ch26+Ch27+Ch28+Ch29+Ch30+Ch31+Ch32
    }
    if(changed(Message)) {
        Scr:writeString(Message,0,0)
    }

    Transmitting Unit Adv. Dupe:
    http://txtb.in/50J

    Receiving Unit Adv. Dupe:
    http://txtb.in/50K


    _________________


    Share this post on: diggdeliciousredditstumbleuponslashdotyahoogooglelive

    avatar

    Post on Sun Sep 27, 2009 2:19 pm by Longino

    don't forget that you've used the mux/demux
    avatar

    Post on Mon Sep 28, 2009 10:41 am by HikariMisako

    Nice, would have been cool if it was morse code or something Razz
    or binary Very Happy
    avatar

    Post on Mon Sep 28, 2009 4:06 pm by Blizzard

    HikariMisako wrote:Nice, would have been cool if it was morse code or something Razz
    or binary Very Happy

    Good idea! I may try to do that Very Happy

    Post  by Sponsored content


      Current date/time is Fri Jan 18, 2019 9:24 pm