Home   Help Search Login Register  

Author Topic: Identify if an object has something in init field  (Read 1771 times)

0 Members and 2 Guests are viewing this topic.

Offline Trexian

  • Members
  • *
Identify if an object has something in init field
« on: 20 Jan 2010, 17:49:46 »
I have an object - like an IED - that has a trigger that is set up at a default distance.  I would like to be able to have a mission maker be able to specify whether to change that distance or not (within a min/max).  But, there may be several IEDs on the map, each with a different size, so I can't really have a global for it, like IED_dist, since it may need to be specific to each IED.

I was thinking that I could have something in the init line - even to call a pre-init type script - to pass the length variable, only for that IED.  I have no clue how to do that, though.

Likewise, I was thinking there might be a way to glean the placement radius of an object, then through scripting, set the object to the actual location it was supposed to be, and use the "radius" as the "length."

Any ideas/suggestions?

Thanks,
T
Sic semper tyrannosauro.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Identify if an object has something in init field
« Reply #1 on: 20 Jan 2010, 19:23:10 »
If I understood you correctly, setVariable / getVariable might help.. :dunno:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Trexian

  • Members
  • *
Re: Identify if an object has something in init field
« Reply #2 on: 20 Jan 2010, 21:40:41 »
Hmmmm... I am familiar with those, but not in this context! :)  So, I'm excited to learn something completely new (to me).

So, let's say there's a model of a flowerpot.  In the model's config, I could flowerPot setVariable ["geranium", 5, true] - and these would be default values.  Then in a script I could flowerPot getVariable "geranium" and it would return 5?

BUT, in the init line of the flowerpot, I could do something like this setVariable ["geranium", 0, true] and it would override the config? :)
Sic semper tyrannosauro.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Identify if an object has something in init field
« Reply #3 on: 20 Jan 2010, 22:48:28 »
Quote
Then in a script I could flowerPot getVariable "geranium" and it would return 5?
Yes.

Quote
BUT, in the init line of the flowerpot, I could do something like this setVariable ["geranium", 0, true] and it would override the config?
It should because I think config init runs before mission init.
Just test it and see what happens :P
« Last Edit: 20 Jan 2010, 22:51:05 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Trexian

  • Members
  • *
Re: Identify if an object has something in init field
« Reply #4 on: 20 Jan 2010, 22:53:57 »
Undoubtedly, I will!  (And report back.) :)

I'm actually quite excited about this now! :D  Thanks!

Edit (since I can't "double post") ;)

Ok, didn't exactly work.  In my config I was trying to set it up as an init eventhandler.  I tried several variations, and this is the only one that didn't throw an error, although it also didn't work. :D

Code: [Select]
class Eventhandlers
{
init = "unit setVariable [""JTD_twLength"", 6, true]; _this execVM ""\@JTD\addons\testing\JTD_Claymore_init.sqf""";
};

I tried _this setvariable, since _this execVM properly passes the identity of the object, but that gave me some sort of error, and the biki used "unit" as the variable that passes through.

I did, however have figure out a workaround thanks to your tip! :)  I noticed that, as is, the JTD_twLength was null.  So, in the init, I getVariable that, and if it is null, I then set it to what I want.  This does also allow, though, for the user, in the init of the object to use this setVariable ["JTD_twLength", 4] to set it to 4 (or any other number).

So, in that sense, THANKS! :)

Now, though, I'd really love to also know how to set a variable as a default in the config, too. :)
« Last Edit: 21 Jan 2010, 17:09:26 by Trexian »
Sic semper tyrannosauro.