+ Reply to Thread
Results 1 to 10 of 10

Thread: I can't get my head around this bug?!

  1. #1
    Wire Noob John-a-tron's Avatar
    Join Date
    Aug 2007
    Posts
    3

    Default

    So i downloaded the Wiremod, verrry pleased with it..

    Followed a few tutorials and JUST as i thought i was getting to grips with it. The I/O radio just fails...

    I have no idea what is going on..

    This was said:
    autorun/server/radiolib.lua:14: attempt to index field 'Entity' (a nil value)[/b]
    so i looked up the directory and into the file:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>
    -- phenex: Start radio mod.
    local radio_channels = {}
    local radio_sets = {}

    function Radio_Register( o )
    table.insert( radio_sets, o )
    end

    function Radio_Transmit( ch, v )
    radio_channels[ch] = v

    for i, o in ipairs( radio_sets ) do
    if (not o.entity:IsValid()) then
    table.remove(radio_sets, i)
    elseif (o.Channel == ch) then
    o:ReceiveRadio(v)
    end
    end
    end

    function Radio_Receive( ch )
    return radio_channels[ch] or 0
    end

    local radio_twowaycounter = 0

    function Radio_GetTwoWayID()
    radio_twowaycounter = radio_twowaycounter + 1
    return radio_twowaycounter
    end

    -- phenex: End radio mod.</div>



    I&#39;m not experienced in the lua coding field one bit so i have no idea what to do...


    I would much appreciate any help given

    Thanks

  2. #2
    Lifetime Supporter DuFace's Avatar
    Join Date
    Aug 2007
    Posts
    234

    Default

    There is a problem with the radio mod that hasn&#39;t been addressed for a while now. Eventually it&#39;ll probably be replaced by a new radio system that philxyz is working on.

    As for that error, it occurs because the field entity is being referenced as an object when it hasn&#39;t been made to equal anything yet (or as Lua says, it is nil). I assume this line here is the culprit:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>...
    for i, o in ipairs( radio_sets ) do
    if (not o.entity:IsValid()) then
    table.remove(radio_sets, i)
    elseif (o.Channel == ch) then
    ...</div>
    Whenever a radio is created it should call that Radio_Register() function so that it is added to the radio_sets table. Then that loop simply checks that each radio is valid (calls the entity:IsValid() function) and then removes the entry if it is invalid, or prompts it to recieve the radio data if it is valid.

    EDIT: Woo this post removed my Newbie status!
    Fields of Green

  3. #3
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default

    Hmmm...as far as I know, you shouldn&#39;t have to set entity to anything, as o refers to a radio entity it is being sent to, and all entities have all their entity-y methods in the entity class. Though I may be wrong, I&#39;m not too great at Lua.

    EDIT: philxyz&#39;s system is for directional radios. These won&#39;t be replacing normal, channel-based radios any time soon. That would be silly.

  4. #4
    Wire Noob John-a-tron's Avatar
    Join Date
    Aug 2007
    Posts
    3

    Default

    So as of now...theres nothing i can do?

    or do i make

    (not o.entity:IsValid())[/b]

    (not o.entity:IsValid()function)[/b]
    I have a feeling im completely missing something

  5. #5
    Lifetime Supporter DuFace's Avatar
    Join Date
    Aug 2007
    Posts
    234

    Default

    philxyz&#39;s system is for directional radios. These won&#39;t be replacing normal, channel-based radios any time soon. That would be silly.[/b]
    Ah my bad, I thought his system included omnidirectional radios too.

    I have a feeling im completely missing something[/b]
    Sorry if I&#39;ve mislead you. Don&#39;t tag function onto the end of that, but make sure the E of Entity is capital. Apart from that I can&#39;t see anything wrong.
    Fields of Green

  6. #6
    Wire Noob John-a-tron's Avatar
    Join Date
    Aug 2007
    Posts
    3

    Default

    Wheyyy!

    Changed it to a capital and its working brilliantly now

    Cheers DuFace =]

  7. #7
    Lifetime Supporter DuFace's Avatar
    Join Date
    Aug 2007
    Posts
    234

    Default

    Any time! Glad I could help
    Fields of Green

  8. #8
    Wire Noob rylasasin's Avatar
    Join Date
    Sep 2007
    Posts
    2

    Default

    i&#39;m currently having this EXACT same problem. However, when I looked in the Lua file, the E was already captalized. What do I do now?

  9. #9
    Wirererer SamPerson12345's Avatar
    Join Date
    Jun 2007
    Posts
    277

    Default

    same problem too. I just updated svn. I&#39;m gonna stick the lua code up here.

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>
    -- phenex: Start radio mod.
    local radio_channels = {}
    local radio_sets = {}

    function Radio_Register( o )
    table.insert( radio_sets, o )
    end

    function Radio_Transmit( ch, v )
    radio_channels[ch] = v

    for i, o in ipairs( radio_sets ) do
    if (not o.Entity:IsValid()) then
    table.remove(radio_sets, i)
    elseif (o.Channel == ch) then
    o:ReceiveRadio(v)
    end
    end
    end

    function Radio_Receive( ch )
    return radio_channels[ch] or 0
    end

    local radio_twowaycounter = 0

    function Radio_GetTwoWayID()
    radio_twowaycounter = radio_twowaycounter + 1
    return radio_twowaycounter
    end

    -- phenex: End radio mod.
    </div>
    I code best at 3 A.M.

  10. #10
    Wirererer SamPerson12345's Avatar
    Join Date
    Jun 2007
    Posts
    277

    Default

    I really hope some lua coder can fix this.
    I code best at 3 A.M.

+ Reply to Thread

Similar Threads

  1. Xtensity's "Spaceman Turret V6" Tutorial, "Head Shots FTW"
    By Xtensity in forum Gate Nostalgia (Old School Wiring) Discussion & Help
    Replies: 24
    Last Post: 09-20-2008, 08:46 AM
  2. Um someting just hit my head.(Idea Ofc)
    By CAANz in forum Ideas & Suggestions
    Replies: 8
    Last Post: 05-12-2008, 01:27 PM
  3. My head just exploded.
    By GreyMario in forum Off-Topic
    Replies: 8
    Last Post: 04-01-2008, 06:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots