Home   Help Search Login Register  

Author Topic: Global Find  (Read 1986 times)

0 Members and 1 Guest are viewing this topic.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Global Find
« on: 27 Oct 2004, 10:00:40 »
Is there a way I find all objects of a specific type on an island?  

What I want to do specifically is find all the streetlights and turn them to OFF.

I am trying to avoid having to find all their object numbers individually

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Global Find
« Reply #1 on: 27 Oct 2004, 11:13:12 »
Yes there is.

You would need to cycle through every object on the island, check if it was a streetlamp and then turn it off if it was.

The last part is very easy, the middle part is quite easy (typeOf command I think) and the first part is hard.    

object 1 is a string, right?    And it is a string that has two parts, "object" and "1".    Making a 1 on its own increment is easy, and it should be possible to add two strings, add a third string for the rest of the code in the line you desire and then use a call command to execute the string you have cobbled together.

Probably.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #2 on: 27 Oct 2004, 11:58:12 »
Wonderful thank you I will have a play with it.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re:Global Find
« Reply #3 on: 28 Oct 2004, 00:19:24 »
I may have a similar need.  Once you get this working, how about posting the solution?  Thanks!
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #4 on: 28 Oct 2004, 07:50:19 »
I would be happy to.  But it might be awhile.  

Does anyone know how I can find the upper range of the object number on any map?  (I presume thje lower limit is 0, or at least if not then starting at 0 will not generate any fatal errors.)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Global Find
« Reply #5 on: 28 Oct 2004, 08:14:00 »
There might be a limit on objects, at least there's a limit on how many textures can be used on an island...

Pure theory, never tested.. :P :
However, when taking object XXXXXX which doesn't exist, it probably returns the "scalar bool array string 0xfcffffef", so you could set up a check in the loop dealing with the objects, in vein of

? (_object == "scalar bool array string 0xfcffffef"): exit

???
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #6 on: 28 Oct 2004, 10:09:50 »
I am sure you are right.  What a pain!  

I don't know if 'scalar bool array string 0xfcffffef' would be recognised as a valid object.

I suppose for each map I could start with a number I know exists and increment and decrement until I get the error at each end of the range.  

That would not work though if the object numbers are grouped with gaps between groups.  I know I would have created a map in that way.  

So much to do and so little time!!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Global Find
« Reply #7 on: 28 Oct 2004, 11:37:49 »
Quote
I suppose for each map I could start with a number I know exists and increment and decrement until I get the error at each end of the range.
The 'scalar bool blah blah' is a valid value, and many scripts use it...

But sadly, I checked this with hint format ["%1",typeOf (object 999999)]
And I get no error altough there's no object 999999 on everon...
object 0 returned 'FuelStation'...

So, you'd be better off to check it with ? _object == "": exit type of thing...
I tried that and it should work...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Global Find
« Reply #8 on: 28 Oct 2004, 11:38:47 »
Try using objNull.

I can't remember if the objects start at 1 or 0.    It's surprisingly easy to find it on BIS islands, it will only take you a minute or two.     Top end is harder, but you only have to find the top number in the areas where there are streetlamps.    It's a slightly longer job but not as grim as you would think.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #9 on: 28 Oct 2004, 11:52:00 »
This is frustrating - I am itching to get at it but I am stuck at work!!  I have just written a script but have no way to test it for several hours.

mac - I have now gone beyond the streetlight thing and want to do something much more general.  The island I am using (Malden) has so few that I could find them all manually quicker than I could debug a script.  But with a script I would the be able to find anything, on any island in the future, as well as sharing it with my friends of course.  Also I think I may not want to turn all the lights  off.

Quote
The 'scalar bool blah blah' is a valid value, and many scripts use it...
Thanks, I didn't know that.


Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Global Find
« Reply #10 on: 28 Oct 2004, 13:08:04 »
Anyway, at least on Everon the objects start from 0..

And no need for objNull, as if you use typeOf in the check and there's no object, typeOf returns an empty string...

As I said, I tried it and it worked... the 'should' is there just for precaution ;D

You would need to come up with something to keep the player enterntained while the script loops through 10000+ objects though...
Will not be a fast task... ::)
« Last Edit: 28 Oct 2004, 13:09:57 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #11 on: 28 Oct 2004, 13:25:56 »
Actually I am thinking of a script to help mission builders to find the objects they want so they can use the obect numbers in their missions.

I agree it could take a long time to do the search everytime the mission is played.

Thanks for the information about the empty string.  The script I have written - but cannot yet test - uses objNull.  If I can't get that to work I will go for the empty string.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re:Global Find
« Reply #12 on: 28 Oct 2004, 16:35:51 »
Maybe this will help determine the upper limit for objids.  Place one new unit on an empty map and get its ID.  I'm assuming units added through mission editor will have a highter number than any object pre-placed in the map.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Global Find
« Reply #13 on: 28 Oct 2004, 16:41:59 »
Negative.
Object IDs are created by the Island creation tool (Visitor/Wrp Edit), the editor placed objects have no IDs...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #14 on: 28 Oct 2004, 20:56:59 »
OK.  So I now have a script that increments the objects from 0 upwards and displays the typeOf that object on the screen.  

But I am now having problems with getting it to take action.

For example:  

I know that (object 37326) is a  StreetLampMetal

but:

if ((object 37326) == StreetLampMetal) then {hint " well this works"}

Does not do anything.

Am I being stupid again?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Global Find
« Reply #15 on: 28 Oct 2004, 22:01:37 »
Maybe you need the typeOf command in there, something like:

if ((object 37326) == typeof "StreetLampMetal") then {hint " well this works"}

Syntax not guaranteed at all.


Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #16 on: 28 Oct 2004, 22:07:17 »
Well I was being stupid

Thanks Plank.  Unfortunately:
if ((object 37326) == typeof "StreetLampMetal") then {hint " well this works"}

generates an error.  but:
if (typeof (object 37326) == "StreetLampMetal") then {hint " well this works"}

is the one I need.

Thanks

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #17 on: 28 Oct 2004, 22:31:27 »
OK.  Attached is a script that searches though the obects in a map to find all objects of a given type.  The script attached will find all:

StreetLampPanel

and all

StreetLampMetal

objects.

Are there any other types of streetlamp?

It is easy to change this script to find any type of object.

What do you think?  Is it worth tidying it up and putting in the Script Beta site?
« Last Edit: 28 Oct 2004, 22:31:47 by THobson »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Global Find
« Reply #18 on: 28 Oct 2004, 22:44:54 »
Well...


StreetLampMetal is configured to use model 'lampazel.p3d'.

StreetLampWood uses 'lampadrevo.p3d

Those are in the Data3d.pbo


The rest are part of Resistance and so will be in the O.pbo:

StreetLampPanel uses 'vo_seda.p3d'
StreetLampPanelAmpl uses 'tlampac_vo_seda.p3d'
StreetLampYellow uses 'vo_zlut.p3d'
StreetLampCut uses 'lampa_cut.p3d'

Those are in O\Misc, apart from the last one which is in O\Hous.

There is another StreetLamp model but I don't know if, or where, it is configured..........O\Misc\vo_stara1.p3d

So.........Yes there are others.

I will try out your script and report back.


Planck
« Last Edit: 28 Oct 2004, 22:49:54 by Planck »
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #19 on: 28 Oct 2004, 22:51:25 »
Thanks.  I will update the script tomorrow to look for the others.

The script above is a little unfriendly.  The one attached will pause after finding each object.

They are both terribly slow

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Global Find
« Reply #20 on: 29 Oct 2004, 01:59:31 »
if (typeOf (object 37326) == "StreetLampMetal") then {hint " well this works"}

Just a guess .... typeOf command missing and also quotes.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #21 on: 29 Oct 2004, 07:50:57 »
Mac.  Thanks for the reply, you are absolutely correct, but we had actually got there at post 16.  

Any thoughts on the script?  It may be that it would only be any use to the newbies like me that havn't yet figured out how to look inside the maps.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #22 on: 29 Oct 2004, 09:01:45 »
I am well on my in tidying up the code and making it more general.  Any comments on its usefulness would be greatly appreciated.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Global Find
« Reply #23 on: 29 Oct 2004, 22:17:11 »
I tried this script and I am happy to report that it found all of the streetlights on Abel (Malden) without a hiccup.

All 12 of them, just in case people wondered how many there were on Malden.

The reported ID numbers were also correct.

It might be useful to make a dialog and expand the script so that a mission maker can input the object, or objects, they wish to search for.


Planck
« Last Edit: 29 Oct 2004, 22:17:55 by Planck »
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #24 on: 29 Oct 2004, 22:39:27 »
Planck:  Thank you.  One thing I don't like about it so far is that the exact object name needs to be used.  I was hoping to be able to search for "Street" to get all the streetlamps,  "Fuel" for all the fuel stations  etc.

This is the subject of a thread I started in Advanced Scripting (String manipulation) so no comments here please on that - I don't want to be accused of starting a duplicate thread.

I too searched Malden for streelamps.  That is where my mission is and I want to turn off all the streetlamps.  I noticec they are all metal.  (I have modified the script to search for all the ones you told me about yesterday)

Is an alternative to this script opening up the map and doing a text search there?  I have no experience of WrpEdit.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Global Find
« Reply #25 on: 29 Oct 2004, 22:56:57 »
Quote
Is an alternative to this script opening up the map and doing a text search there?  I have no experience of WrpEdit.

No, Wrpedit does not show you the ID numbers.

Wrpedit will show you the p3d file names on each object that you hover the mouse over.
It does not give you the object name or the ID number.

So, you won't be able to do it that way either.......sorry


Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Global Find
« Reply #26 on: 30 Oct 2004, 07:37:09 »
Thanks.  Pity.