red62dota
Member-
Content Count
7 -
Joined
-
Last visited
-
Medals
Community Reputation
0 NeutralAbout red62dota
-
Rank
Rookie
-
Local variables not defined inside control structures in script?
red62dota replied to red62dota's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks. I only have a couple years of Java and Python experience, and I have been trying to work through a couple scripts in my unit's modpack to try to understand them, but I find this language incredibly hard to read in general. Your code looks beautiful, but I am definitely going to have to read up on some Arma 3 specific control structures, reserved commands and variable interaction before I am able to trace it and fully understand it. Thanks again for your assistance. -
Local variables not defined inside control structures in script?
red62dota replied to red62dota's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Everything works fine when the vars are all global, but when I switch them to local they do not get propagated down from the main body of the script into ANY control structures or anything with brackets in it whatsoever -
Local variables not defined inside control structures in script?
red62dota replied to red62dota's topic in ARMA 3 - MISSION EDITING & SCRIPTING
The while loop checks if the addactions have been given to the unit, and if so it sleeps 1 then repeats until one of the addactions has been selected by the unit, in which case the script can proceed to the next block - it happens sequentially. I know I should name my variables better, sorry about that -
Local variables not defined inside control structures in script?
red62dota posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello, I have been working on this code for a mission for the past couple hours. I need to call it with four different units, like this: [bLUF_LEAD, "blufor_asset_1", "blufor_asset_2", "blufor_asset_3", "blufor_asset_4"] execVM "assets_core.sqf"; Before I attempted to call it with two units, every part of the script worked fine, but when I attempted to call it with the second team lead I realized that all the variables were global and it screwed up everything. In an attempt to fix this, I made all the unit and asset1-4 variables local - but now they do not get passed to the rest of the script for some reason. I get an undefined variable error around line 54 when I try to use _asset1. Can someone please help me figure out why my local variables (which should have a scope of the entire script) are not usable throughout the entire script? Many thanks. /* DONE: define spawn locations for assets, boxes etc - primary spawn, secondary spawn blufor_asset_1-4 civ_asset_1-4 indfor_asset_1-4 redfor_asset_1-4 */ sleep 2; _unit = _this select 0; _asset1 = _this select 1; _asset2 = _this select 2; _asset3 = _this select 3; _asset4 = _this select 4; //DIFFERENTIATE BETWEEN RIFLES if (side _unit == west) then { dmrScope = "rhs_acc_1p78"; redDot = "CUP_optic_Kobra"; silencer = "rhs_acc_tgpa"; }; if (side _unit == east) then { dmrScope = "RH_ta31rco"; redDot = "FHQ_optic_AC11704"; silencer = "CUP_muzzle_snds_G36_black"; }; if (side _unit == resistance) then { dmrScope = "RH_ta31rco"; redDot = "optic_Aco"; silencer = "muzzle_snds_M"; }; if (side _unit == civilian) then { dmrScope = "RH_ta31rco"; redDot = "optic_Aco"; silencer = "muzzle_snds_B"; }; //PICK PRIMARY ASSET a = 0; while {a != 1} do { if (a == 0) then { _unit addAction ["1x HMMWV (M2)", {a = 1; _veh = "rhsusf_m1025_d_m2" createVehicle(getMarkerPos _asset1); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; removeAllActions _unit;}]; _unit addAction ["2x HMMWV (UNARMED)", {a = 1; _veh = "rhsusf_m1025_d" createVehicle(getMarkerPos _asset1); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; _veh = "rhsusf_m1025_d" createVehicle(getMarkerPos _asset4); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; removeAllActions _unit;}]; _unit addAction ["1x Littlebird (UNARMED)", {a = 1;_veh = "CUP_B_MH6J_USA" createVehicle(getMarkerPos _asset1); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; removeAllActions _unit;}]; _unit addAction ["1x HMMWV (GPMG)", {a = 1;_veh = "CUP_B_HMMWV_MK19_USA" createVehicle(getMarkerPos _asset1); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; _veh setVehicleAmmo .18; removeAllActions _unit;}]; _unit addAction ["4x Quadbike", {a = 1; _veh = "C_Quadbike_01_F" createVehicle(getMarkerPos _asset1); _veh = "C_Quadbike_01_F" createVehicle(getMarkerPos _asset1);_veh = "C_Quadbike_01_F" createVehicle(getMarkerPos _asset1);_veh = "C_Quadbike_01_F" createVehicle(getMarkerPos _asset1); removeAllActions _unit;}]; _unit addAction ["1x HMMWV (TOW)", {a = 1; _veh = "CUP_B_HMMWV_TOW_USMC" createVehicle(getMarkerPos _asset1); clearWeaponCargo _veh; clearMagazineCargo _veh; clearBackpackCargo _veh; _veh setVehicleAmmo .40; removeAllActions _unit;}]; a = 2 }; sleep 1; }; sleep 2; //PICK SECONDARY ASSET box = "Box_East_Ammo_F" createVehicle(getMarkerPos _asset2); clearMagazineCargo box; b = 0; while {b != 1} do { if (b == 0) then { _unit addAction ["1x L115A1 Sniper w/ optics", {b = 1; box addWeaponCargo ["CUP_srifle_AWM_des",1]; box addMagazineCargo ["CUP_5Rnd_86x70_L115A1",10]; box addItemCargo ["CUP_optic_LeupoldMk4_10x40_LRT_Desert",1]; removeAllActions _unit;}]; _unit addAction ["2x AA12", {b = 1; box addWeaponCargo ["CUP_sgun_AA12",2]; box addMagazineCargo ["CUP_20Rnd_B_AA12_Pellets",16]; box addMagazineCargo ["CUP_20Rnd_B_AA12_74Slug",16]; removeAllActions _unit;}]; _unit addAction ["2x M249", {b = 1; box addWeaponCargo ["rhs_weap_m249_pip_L",2]; box addMagazineCargo ["rhs_200rnd_556x45_M_SAW",16]; removeAllActions _unit;}]; _unit addAction ["2x M136 HEDP", {b = 1; box addWeaponCargo ["rhs_weap_M136_hedp",2]; removeAllActions _unit;}]; _unit addAction ["2x M16 (M203)", {b = 1; box addWeaponCargo ["rhs_weap_m16a4_carryhandle_M203",2]; box addMagazineCargo ["rhs_mag_30Rnd_556x45_Mk318_Stanag",16]; box addItemCargo ["1Rnd_HE_Grenade_shell",60]; removeAllActions _unit;}]; _unit addAction ["4x Mini Uzi w/ Suppressor", {b = 1; box addWeaponCargo ["CUP_hgun_MicroUzi",4]; box addMagazineCargo ["CUP_30Rnd_9x19_UZI",50]; box addItemCargo ["CUP_muzzle_snds_MicroUzi",4]; removeAllActions _unit;}]; b = 2; }; sleep 1; }; //PICK TERTIARY ASSET sleep 2; a = 0; while {a != 1} do { if (a == 0) then { _unit addAction ["2x IED", {a = 1; box addItemCargo ["CUP_IED_V1_M",2]; removeAllActions _unit;}]; _unit addAction ["6x M15 AT Mine", {a = 1; box addItemCargo ["ATMine_Range_Mag",6]; removeAllActions _unit;}]; _unit addAction ["12x L109 Frag", {a = 1; box addItemCargo ["CUP_HandGrenade_L109A1_HE",12]; removeAllActions _unit;}]; _unit addAction ["10x M84 Stun", {a = 1; box addItemCargo ["rhs_mag_mk84",10]; removeAllActions _unit;}]; _unit addAction ["15x M18 Smoke", {a = 1; box addItemCargo ["SmokeShellBlue",15]; removeAllActions _unit;}]; _unit addAction ["2x Steerable Parachute", {a = 1; box addBackpackCargo ["B_Parachute",2]; removeAllActions _unit;}]; _unit addAction ["4x Red dot", {a = 1; box addItemCargo [redDot,4]; removeAllActions _unit;}]; _unit addAction ["4x Suppressor", {a = 1; box addItemCargo [silencer,4]; removeAllActions _unit;}]; _unit addAction ["2x DMR optics", {a = 1; box addItemCargo [dmrScope,2]; removeAllActions _unit;}]; _unit addAction ["Extra medical supplies", {a = 1; box addItemCargo ["ACE_elasticBandage",30]; box addItemCargo ["ACE_packingBandage",30]; box addItemCargo ["ACE_morphine",15]; box addItemCargo ["ACE_epinephrine",15]; box addItemCargo ["ACE_personalAidKit",10]; box addItemCargo ["ACE_salineIV_250",10]; removeAllActions _unit;}]; a = 2; }; sleep 1; }; //TODO: delete border fences around units after 2 minutes or so -
Scripting Introduction for New Scripters
red62dota replied to Ranwer135's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Really informative post, thanks! Trying to make a mission myself- 97 replies
-
Use of underscore Syntax
red62dota replied to sw1's topic in ARMA 2 & OA : ADDONS - Configs & Scripting
Thanks for this info! -
Post New Thread Button missing?
red62dota replied to mdtorch's topic in BOHEMIA INTERACTIVE: Web-Pages
Thanks for this information! No rules were sent to me when I signed up through steam :\