cuel 25 Posted September 3, 2012 object getVariable ["someVar",false] will return false if the variable does not exist (is nil) for that object. so basically what it says is if (!(false)) then { // we got in } "not false" is true. "not true" (as you suggested) is false. Share this post Link to post Share on other sites
zorilya 0 Posted September 3, 2012 so on that would object getvariable ["somevar",true] also return false if the variable was nil? Share this post Link to post Share on other sites
cuel 25 Posted September 3, 2012 It would return true in your example. It will return the second value in the array if the variable was nil. Otherwise the value of the variable. _r = object getVariable ["someVar",true]; hint str _r; _r is true. You can also do stuff like _r = (object getVariable ["someVar","Hello"]); hint str _r; _r is "Hello" http://community.bistudio.com/wiki/getVariable object getVariable [name, defaultValue] Parameters: object: Object or Location name: String - Variable name that was defined in setVariable (Case sensitive) defaultValue: Any Value - Value to return if variable doesn't exist Returns defaultValue if the variable doesn't exist. Returns Anything if the object is undefined. Share this post Link to post Share on other sites
zorilya 0 Posted September 4, 2012 Wouldn't it be easier to just set a variable on the house to indicate that it's occupied instead of pushing them all into huge sqf files? I've used that before and it worked quite well :)e.g _house setVariable ["TAG_occupied",true]; and then later if (!(_someOtherHouse getVariable ["TAG_occupied",false])) then { _someOtherHouse setVariable ["TAG_occupied",true]; // code to insert units into house }; i'm afraid i'm still; having trouble with you example... ok so ... in the second example the false is the value to return if the variable is undefined right? so if it's undefined the house hasn't been entered and your making of that variable into true would be the prompt for units to garrison. If that variable returned true, that would mean the house was already garrisoned and the else statement could klick in with //select another house. did i get that right? Share this post Link to post Share on other sites
cuel 25 Posted September 4, 2012 You don't have to use my example. You can code it anyway you want :). getVariable array will return the 2nd value IF the variable is undefined, otherwise it will return the value of the variable. Let's break it down, first off: boolean values can only be TRUE or FALSE. When we find a house and put some units inside it, we'll want to set the variable to true. // code to add units to the house, and then set the variable: _house setVariable ["TAG_occupied",true]; That means it already has units inside it. Later on, we'll have some other units that we want to put inside a house. WRONG: if (_house getVariable ["TAG_occupied",false]) then { // this will only run on houses that [b]already [/b]has units inside it }; If the house that we have selected for the second group is already occupied, that if statement will return true since the variable already exists for that house. If not, it will return false. Let's assume that the house we have selected already has units inside, that means that the above if statement basically says: if (true) then { //this runs every time }; If it doesn't have units inside, it will return false, as in if (false) then { // this will never run }; That's why we add the exclamation mark, which means NOT if (!false) then { // this will run (not false is equal to true) }; if (!true) { // this will not run. (not true is equal to false) }; So, if the house has no units inside it, the variable is undefined and that's why we want to return false. If it has units inside it, it will return true (!true doesn't run, !false does run, remember the boolean only has two values). That's why we return false and add the exclamation mark. If you define the 2nd value in the getVariable array as TRUE, it will always return true, it doesn't matter if we already set the variable to true earlier. Short example: // let's assume that _house is defined as a random house from some code above if !(_house getVariable ["TAG_occupied",false]) then { // we're inside this if-statement, that means that the house did not have the variable set to true. // let's make sure we never select this house again: _house setVariable ["TAG_occupied",true]; // some code here // to fill the house with units }; Share this post Link to post Share on other sites
zorilya 0 Posted September 4, 2012 I must say it was only the setvariable and getvariable that were confusing me so thanks for the description of that, however i don't know where i gave you the impression i didn't understand what a boolean was, or the values therein. In the description of getvariable on biki is said the second param was a default value and i accidently applied that to the setvariable parameters hence my question about the default param. considering your description was heavily geared towards the mechanics of boolean values i must ask... do you really think that someone without a basic grasp of the concept of true and false, applied as an if condition, could really have written any useful code let alone something a little larger i.e. my script? As much as i appreciate the effort that went into this description i would ask that you step back for a second and look at the bigger picture before describing something that doesn't need to be described, as it can be not only a waste of your time, but can easily come off as insulting as i'm afraid it has in this case. Also, as much as i am an advocate of making thorough explainations, there is a certain level of understanding that one displays when asking a question that i don't believe you assessed correctly. Considering what i got from your answer, and the discussion we had before, a simple confirmation was all that was needed unless ofcourse you didn't understand what i was saying, in which case disregard this sentence. I mean this in a purely constructively critical way and i hope you understand that this is not out of spite or anything. i mean why would it be ... i don't even know you hehe. once again thankyou for the set and getvariable explaination and i will try and get this worked in shortly when i'm finished blowing stuff up. Share this post Link to post Share on other sites
cuel 25 Posted September 4, 2012 My intention was not to insult you, I was just breaking it down in case someone else comes across it :). I realise that my first description was a bit vague Share this post Link to post Share on other sites
twirly 11 Posted September 5, 2012 Seems like someone is having a bad day! Arma 2 scripting can do that :) Share this post Link to post Share on other sites
zorilya 0 Posted September 20, 2012 updated to v1.1 available in the WIP section on Armaholic http://www.armaholic.com/forums.php?m=posts&p=127700#127700 sadly haven't been working on the feature mentioned above. had other scripts taking up my time but i will get round to it. Share this post Link to post Share on other sites
Guest Posted September 21, 2012 (edited) Thanks for sending us the release :cool: Release frontpaged on the Armaholic homepage. Garrison script v1.2 Edited September 23, 2012 by Guest updated mirror Share this post Link to post Share on other sites
zorilya 0 Posted September 23, 2012 updated to v1.2 added that occupied check so you can now mass dump units and they'll sort themseves out... much better hehe. also added a patrol script for where there are no buildings left to occupy. http://www.armaholic.com/forums.php?m=posts&q=18669&d=0 enjoy Share this post Link to post Share on other sites
The Hebrew Hammer 10 Posted September 24, 2012 Do you have an example mission? I'm trying to get this working on CLAfghan, it keeps returning "no buildings" Share this post Link to post Share on other sites
zorilya 0 Posted September 24, 2012 any more detail on what your doing... how are you executing the world_build_list and the position on the map your guys are at? Share this post Link to post Share on other sites
zorilya 0 Posted September 28, 2012 Updated to v1.3, changes include now working on any map , no longer needs the world_build_list.sqf. improved occupied variable check to stop double ups in buildings when two groups are in close proximity and units crouch on when high enough in a building and look around more. http://www.armaholic.com/forums.php?m=posts&q=18669&d=0 enjoy Share this post Link to post Share on other sites
metalcraze 290 Posted October 3, 2012 Would be cool to get that 'staring at a wall' check in the script you mentioned in the video. Share this post Link to post Share on other sites
Guderian 10 Posted October 3, 2012 Coudnt get it to work in Arma2Free.. Share this post Link to post Share on other sites
zorilya 0 Posted October 3, 2012 working on it as we speak :) Share this post Link to post Share on other sites
zorilya 0 Posted October 4, 2012 wait that was in response to the looking at walls comment... what's happening on your end ... it should work with arma free as i'm pretty sure it uses the same library of data and configs. could you detail please? list the map, the location and exactly what you are putting in the initline. and obviously the outcome hehe Share this post Link to post Share on other sites
Guderian 10 Posted October 5, 2012 They just stand there, en the hint (time) isnt comming. I placed some extra debug hints in the script and it seems to run, but stalls somewhere. I used OPFOR soldiers, the init on the leader was: nul = [this,300,true] execVM "Garrison_script.sqf"; Also tried to name the leader like L1: nul = [L1,300,true] execVM "Garrison_script.sqf"; Played on Chernarus. Share this post Link to post Share on other sites
zorilya 0 Posted October 5, 2012 the time hint should be commented out. according to everything else it should be working... probably a silly question but, are there any enterable buildings in the 300m area? have you found out at what point it stalls? have you got all the relevant scripts in a folder named scripts of the mission file? Share this post Link to post Share on other sites
Guderian 10 Posted October 6, 2012 yes,yes and yes. Next to the appartment buildings in cherno. Share this post Link to post Share on other sites
zorilya 0 Posted October 6, 2012 what point does it stall at? Share this post Link to post Share on other sites
zorilya 0 Posted October 10, 2012 i can't help you if you don't reply man. Share this post Link to post Share on other sites
Guderian 10 Posted October 11, 2012 Sorry, been busy.. will check this weekend and report! Share this post Link to post Share on other sites