Jump to content

dynamically created statics , can't get position info etc..


Lineaxe

Recommended Posts

I am looking hard for the syntax that will allow my to access my dynamically created static objects properties such as it's location and other functions in it's class .. I can't find any examples anywhere,, here is some of the code I found while looking online that has been modified a bit

 

local statObjArr = coalition.getStaticObjects(2) --(1=Red 2=Blue)

for i, staticObj in pairs(statObjArr) do

local teststaticName = staticObj:getName()

trigger.action.outText(teststaticName , 5)

--this outputs each name

-- I don'tknow at this point if staticObj as used here is a valid objectthat I can get properties from... so far I don't have the correct syntax. And can't find examples anywhere.

 

currentStaticObj= StaticObject.getByName(teststaticName )

 

-- compiles .should now return a valid static object I can use?

 

:

failme = STATIC:FindByName( teststaticName )

STATIC not found for: teststaticName ---ERROR: actual name replaces the variable , and so on while i try to guess at the syntax needed to be able to use the properties of each coaltion.staticobject

.


Edited by Lineaxe
modified
Link to comment
Share on other sites

@LineAxe

 

The functions listed in Hoggit Wiki should work.

 

Yes, StaticObject.getByName("name of the static in ME") should work, just like STATIC:FindByName("name of the static in ME") .

 

Keep in mind, however, that some static objects won't cooperate (such as static soldiers, IIRC). Still, you should be able to work with most static types.

 

What do you mean by "properties"? Position coordinates? Could you be more specific?

Link to comment
Share on other sites

I want to access features similar to what can be done with SET_Static: where the static elements are created inside of mission editor instead of on the fly in lua code . I can get access to these

functions and run them with arguments the first way but not dynamically through code. functions such as the one that finds out if they are in our outside a certain zone and returns accordingly.

This is not a problem from the staticobjects created inside of mission editor.

 

oh....

i created these static objects earlier using

coalition.addStaticObject(country.id.USA, mynewStaticObjArr)

 

..now I can't actually get any static object info such as health etc...or run any kind of tests using their subroutines (functions)


Edited by Lineaxe
Link to comment
Share on other sites

Ok, so the problem is that you're having trouble getting dynamically spawned statics to cooperate, right?

 

By "cooperate" I mean stuff like returning health, name, position coordinates, etc.

 

Right now I can't remember if dynamically spawned statics actually worked with the methods you mentioned... but I do know that they yield basic info.

 

For instance, they should be detected by birth events, event.initiator and event.initiator:getCategory() (perhaps even :getPoint() and others as well) should work, IIRC.

 

You can also try event.initiator:getDesc(), see if you get a basic description table with some useful info in it.

 

If not, you can always access the parameters within the template table you used for coalition.addStaticObject().

 

It should contain x and y coordinates at the very least (that should be enough to get zone checks working), and you can always customize it, adding all the parameters you'll need (sort of a custom description table).


Edited by Hardcard
Link to comment
Share on other sites

thanks for that. Now I won't be trying to muck about trying to find classes that would work with a coalition.static object . I had created a larger table that held each objects attributes such as name, position, etc. But I had heard about using sets and the advantage and so tried to set up coalition objects like those inside a set.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...