Home   Help Search Login Register  

Author Topic: One script for lots of objects  (Read 1631 times)

0 Members and 1 Guest are viewing this topic.

marcus3

  • Guest
One script for lots of objects
« on: 17 Jul 2005, 18:10:14 »
waht is the best way to make a script that will be used by lots of objects for the same thing? i want to use it for cutting down tree's but i dont want to have to name every tree over and over again. uderstand? something like this. in the init of the tree i put

[this] exec "thescript.sqs"

and the script something liek this

_tree = _this select 0

@( man distance _tree < 3)

cut = man addaction ["cut the tree","cutree.sqs"]

bla bla bla

bla bla bla


and that is as far as i got. so if u can help please for god's sake do!

thanks




Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:One script for lots of objects
« Reply #1 on: 17 Jul 2005, 20:38:59 »
Have you looked at the nearestObject command?
« Last Edit: 18 Jul 2005, 07:46:37 by THobson »

marcus3

  • Guest
Re:One script for lots of objects
« Reply #2 on: 18 Jul 2005, 04:16:14 »
i have could not figuar out how it works or how to use it.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:One script for lots of objects
« Reply #3 on: 18 Jul 2005, 07:47:56 »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:One script for lots of objects
« Reply #4 on: 18 Jul 2005, 21:05:15 »
I would suggest adding the action to the tree itself, instead of the player. It would make things much simpler.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

marcus3

  • Guest
Re:One script for lots of objects
« Reply #5 on: 19 Jul 2005, 00:51:12 »
he he.........how?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:One script for lots of objects
« Reply #6 on: 19 Jul 2005, 04:01:56 »
do you mean like the map objects or a tree placed in the editor (from an addon or something)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:One script for lots of objects
« Reply #7 on: 19 Jul 2005, 07:48:45 »
It shouldn't matter.  Each object on the map has an ID number.  Just create an array of ID numbers for the trees you want to deal with and away you go.

{(object _x) addAction [{actioname},{action.sqs}]} forEach [1234,5678,90123....]

Where the numbers in the array or the object IDs

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:One script for lots of objects
« Reply #8 on: 19 Jul 2005, 14:31:14 »
well if its placed from the editor, say from an editor Upgrade, would they still have the object ids? if so, does every unit get assign an id then?

Offline Pilot

  • Contributing Member
  • **
Re:One script for lots of objects
« Reply #9 on: 19 Jul 2005, 14:38:26 »
No, in this case you would have to give the object a name, and then use that name in place of object xxxxx in THobson's above example

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:One script for lots of objects
« Reply #10 on: 19 Jul 2005, 18:01:04 »
well thats what i thought, but thobson said it didn't matter (thobson knows a lot  ;))

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:One script for lots of objects
« Reply #11 on: 19 Jul 2005, 18:16:25 »
Sorry I was not clear.  I did say:
Quote
Each object on the map has an ID number
What I didn't say - in part because this is the Advanced Editing board - is that any object you add would as Student Pilot points out, either need to have a name or be acted on through its init  field.

This is more general:

{_x addAction [{actioname},{action.sqs}]} forEach [object 1234,object 5678,object 90123, name1,name2....]

Where the numbers are what you get when you look at object IDs in the editor, and the names are the name you give the objects you place on the map.

« Last Edit: 19 Jul 2005, 21:16:21 by THobson »

marcus3

  • Guest
Re:One script for lots of objects
« Reply #12 on: 20 Jul 2005, 01:54:17 »
me bea trying tis.....

marcus3

  • Guest
Re:One script for lots of objects
« Reply #13 on: 20 Jul 2005, 02:22:37 »
(wow i thought i new alot :-[) ok i did that and it worked (kinda)
but in the script i need to be able to delete the tree that u "Cut"
but if the action is add did to all of them then how can u delete that one tree?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:One script for lots of objects
« Reply #14 on: 20 Jul 2005, 04:09:24 »
in the action script:
_tree = _this select 0
deletevehicle _tree


oh wait *slaps forehead* the closest you can get for map objects AFAIK is setdammage

marcus3

  • Guest
Re:One script for lots of objects
« Reply #15 on: 20 Jul 2005, 04:36:40 »
YAHHOOOO!!!! it work's thanks guys!