Help - Coding Custom WIFI with Lua

  • OmegaSupreme
    5th May 2014 Member 1 Permalink

    I fool around with the Lua console and with Lua scripts in TPT. I also create custom elements using Lua scripts. I thought of an excellent idea yesterday for a Pressure Proof Wifi element, but I don't know how to go about coding it because I kept getting "Unmatched Bracket" while attempting to replicate WIFI's code from 89.0. I want to make Atmoshperic WiFi 1 (AWF1) and Atmospheric Wifi 2 (AWF2) using the Lua console, but I wouldn't know how to code the extra part after the basics.

    Any help would greatly be appreciated.
    Thanks!

  • boxmein
    5th May 2014 Former Staff 1 Permalink
    You could try something like this in pseudocode:
    for every particle with type "AWF1" do
    if that particle's ctype is the same as this one's
    for every particle around that particle
    if around-particle is a metal
    change its type to SPRK(that metal)
    end
    end
    end
    end
  • jacob1
    5th May 2014 Developer 0 Permalink
    @OmegaSupreme (View Post)
    recreating WIFI would be pretty hard, since WIFI uses a lot of extra data and does other complicated things. WIFI stores info in a variable called wireless[CHANNELS][2], I think. When WIFI detect sparks it sets wireless[channelhere][0] to true. Some update thing that runs every frame before the particles update then loops through, and sets wireless[channelhere][1] to true if [0] was true. WIFI then sparks other elements if wireless[channelhere][1] is true. This is just from memory, but I Think that should work. It also avoids particle order issues, mostly ...

    boxmein's psuedocode should basically show how to spark things / detect spark. Except I wouldn't do the massive loop over every particle like he does.
    Edited once by jacob1. Last: 5th May 2014
  • OmegaSupreme
    6th May 2014 Member 0 Permalink

    But I don't know how to do psuedocode. Sorry, but when I said I knew the basics, I meant:

    local atmwifi1 = elements.allocate("OSCE", "AWF1")
    elements.element(elements.OSCE_PT_AWF1, elements.element(elements.OSCE_PT_AWF1))
    elements.property(elements.OSCE_PT_AWF1, "Name", "UQRK")
    elements.property(elements.OSCE_PT_AWF1, "Description", "AWF1. Atmospheric WiFi One. Wifi Designed for use in Pressurized Invironments.")
    elements.property(elements.OSCE_PT_AWF1, "Colour", 0x000000) <- I'm going to make it Light Blue
    elements.property(elements.OSCE_PT_AWF1, "MenuVisible", 1)
    elements.property(elements.OSCE_PT_AWF1, "MenuSection", SC_ELEC)
    elements.property(elements.OSCE_PT_AWF1, "Advection" 0.0)
    elements.property(elements.OSCE_PT_AWF1, "AirDrag", 0.0)
    elements.property(elements.OSCE_PT_AWF1, "AirLoss", 0.00)
    elements.property(elements.OSCE_PT_AWF1, "Loss", 0.0)
    elements.property(elements.OSCE_PT_AWF1, "Collision", 1)
    elements.property(elements.OSCE_PT_AWF1, "HeatConduct", 1)
    elements.property(elements.OSCE_PT_AWF1, "Gravity", 0)
    elements.property(elements.OSCE_PT_AWF1, "Diffusion", 0)
    elements.property(elements.OSCE_PT_AWF1, "HotAir", 0.0)
    elements.property(elements.OSCE_PT_AWF1, "Falldown", 0.0)
    elements.property(elements.OSCE_PT_AWF1, "Flammable", 0)
    elements.property(elements.OSCE_PT_AWF1, "Explosive", 0)
    elements.property(elements.OSCE_PT_AWF1, "Meltable", 0)
    elements.property(elements.OSCE_PT_AWF1, "Hardness", 100)
    elements.property(elements.OSCE_PT_AWF1, "Weight", 0)
    elements.property(elements.OSCE_PT_AWF1, "Temperature", 273.15)
    elements.property(elements.OSCE_PT_AWF1, "HeatConduct", 0)
    elements.property(elements.OSCE_PT_AWF1, "State", ST_SOLID)
    elements.property(elements.OSCE_PT_AWF1, "Properties", elem.TYPE_SOLID)
    elements.property(elements.OSCE_PT_AWF1, "LowPressure", IPL)
    elements.property(elements.OSCE_PT_AWF1, "LowPressureTransition", NT)
    elements.property(elements.OSCE_PT_AWF1, "HighPressure", IPH)
    elements.property(elements.OSCE_PT_AWF1, "HighPressureTransition", NT)
    elements.property(elements.OSCE_PT_AWF1, "LowTemperature", ITL)
    elements.property(elements.OSCE_PT_AWF1, "LowTemperatureTransition", NT)
    elements.property(elements.OSCE_PT_AWF1, "HighTemperature", ITH)
    elements.property(elements.OSCE_PT_AWF1, "HighTemperatureTransition", NT)

    (WHERE COMPLEX CODE WILL GO FOR AWF1) <-- I don't know how to code this section in "Simple Terms" like the above.


    I only know how to do this much, and I know from looking at the code that the above won't be enough to create my own wifi. I probably got off to a bad start by now specifically asking what exactly I needed help coding. A Step-by-step explanation would be perfect if possible! :D

    Edited once by OmegaSupreme. Last: 6th May 2014