Forged Alliance Forever Forged Alliance Forever Forums 2015-12-30T15:54:33+02:00 /feed.php?f=41&t=11377 2015-12-30T15:54:33+02:00 2015-12-30T15:54:33+02:00 /viewtopic.php?t=11377&p=116764#p116764 <![CDATA[Re: question about lua]]>

thank you so much for the help Myxir !

Statistics: Posted by asimov59 — 30 Dec 2015, 15:54


]]>
2015-12-30T15:18:23+02:00 2015-12-30T15:18:23+02:00 /viewtopic.php?t=11377&p=116762#p116762 <![CDATA[Re: question about lua]]> i advise to use the common mod tools mod by Crotalus for this

Code:
local units = import('/mods/common/units.lua')

function getUnitsInRect(x0, z0, x1,z1)
    local inRect = {}
    local pos, x, z = {}, 0, 0
    for _,u in units.Get() do
        pos = u:GetPosition()
        x, z = pos[1], pos[3]
        if (x >= x0) and (x <= x1) and (z >= z0) and (z <= z1) then
            table.insert(inRect, u)
        end
    end
    return inRect
end


do not forget to require the mod for your own though (in your mod info file), to ensure you don't run into import errors
Code:
requires = {"zcbf6277-24e3-437a-b968-Common-v1"}

Statistics: Posted by Myxir — 30 Dec 2015, 15:18


]]>
2015-12-30T15:00:13+02:00 2015-12-30T15:00:13+02:00 /viewtopic.php?t=11377&p=116759#p116759 <![CDATA[Re: question about lua]]>
If I understand, If I want to get some units with UnitInRect and draw informations about these units i must get the data somewhere in Sim and use UserSync to have theses data available from UI.

I think it should take me some time to understand that.

First mod i want to do is an economic helper, so i want access eco data to all of my units, do some stuff on data and draw infos on screen. Are they already available from UI ?

And last it's more an ethic question (probably better ask in other topic),

making a predictive economic graph(how is your eco and how much ressource in the next few minuts based on actual ressource and engies and structure action stack) is a borderline mod you think ? I have some pros and cons in mind

Statistics: Posted by asimov59 — 30 Dec 2015, 15:00


]]>
2015-12-30T14:21:30+02:00 2015-12-30T14:21:30+02:00 /viewtopic.php?t=11377&p=116756#p116756 <![CDATA[Re: question about lua]]> if that does not work for you, you're probably tinkering with UI code, which is unable to use the Sim functions

http://wiki.faforever.com/index.php?tit ... Sim_and_UI

Statistics: Posted by Myxir — 30 Dec 2015, 14:21


]]>
2015-12-30T14:17:11+02:00 2015-12-30T14:17:11+02:00 /viewtopic.php?t=11377&p=116755#p116755 <![CDATA[question about lua]]>
First sorry because my english is bad, so thank you for doing the reading effort.

I have some idea for FA mods and i want to create them, for information i have already using lua for scripting (crysis war on server side) so i'm not totally noob but not so good too ;)

I have find a quick reference here: http://supcom.wikia.com/wiki/LUADOC_1.5.3599

So i want to do some test with GetUnitsInRect()

When i try to call it i have a message error : "access to nonexistent global..."

No problem: i search in all Lua file the GetUnitsInRect déclaration location and next i import the function. But i don't see the declaration anywhere.

In wiki this function is under "Sim.<global>"

My question is pretty simple finally: how to call a function declared under "scope" like Sim.<global> for example ?


I'm sure is quite simple but i'm totally blocked with that.

Best Regard,

asimov59

Statistics: Posted by asimov59 — 30 Dec 2015, 14:17


]]>