Tomsk 0 Posted October 17, 2011 Hello, I have a large number of scripts that I'd like to share between several different missions. So I had the clever idea that rather than copying each script into each mission folder, and ending up with 10 versions of each script. Instead I should put them in a PBO and stick that in a mod folder and load my scripts as a mod. I've found the cpbo tool and have worked out how to create the .pbo file with the scripts in it, how to create a mod folder and have Arma2 load the mod and all the rest. What I haven't found out is how I can use my scripts from my mission files. I used to use: #include "Tomsk_Utils.sqf" to load the functions in one of my utility scripts. This worked fine when their was a copy of that script in the same folder as the mission. But having moved the script to a .pbo this doesn't work any more. Does anyone know how I can make use of the functions and macros in my script now the script is in a PBO? Cheers Tomsk Share this post Link to post Share on other sites
[frl]myke 14 Posted October 17, 2011 It is much simpler than that. nul = this execVM "/addonName/subFolder/myScript.sqf"; addonName is obviously the pbo name you gave it. subFolder is a subfolder (duh) in which the final script is located. So, the path is the key. Without any explicit path definition (as in your example), the engine looks for the script in the mission pbo itself. So just get the path right and you're good to go. As a sidenote, such threads belong into the editing section, not the addon discussion forum. 1 Share this post Link to post Share on other sites
dmarkwick 261 Posted October 17, 2011 You can make a "scripts" folder inside your MyDocs\ArmA2 folder and your scripts will be found there as though they were in your missions folder. When you eventually need to distribute your mission you then copy the script into the mission folder just prior to PBOing, but until then, you can keep any script you like right in the MyDocs\ArmA2\scripts folder and all your missions will see it/them. Share this post Link to post Share on other sites
Gunter Severloh 4062 Posted October 18, 2011 Quote nul = this execVM "/addonName/subFolder/myScript.sqf"; Using this seems specific to one script, how would work with multiple scripts? Just by having multiple scripts in a scripts folder using that lien the scripts will be called and used ingame? this line of code is put into a trigger in the mission, or cant the scripts just be run by just having the pbo set up like a mod folder as said by the OP? Another question, if you make a pbo that has scripts that contain init scripts and other scripts related to run how will those be used or accessed, dont you need to call them somehow? Share this post Link to post Share on other sites
Gunter Severloh 4062 Posted October 18, 2011 Can you guys answer my questions?, trying to learn how this works as i'd like to apply this outside of missions. How does an addon work in general I mean what i always wanted to know is how does the game run the information in the pbo? Lets say you have downloaded an addon that adds some gameplay feature, how is that called, or rather how does the game recognize the addon and execute the change or addition ingame? Share this post Link to post Share on other sites
loyalguard 15 Posted October 19, 2011 Can you guys answer my questions?, trying to learn how this works as i'd liek to apply this outside of missions.How does an addon work in general I mean what i always wanted to know is how does the game run the information in the pbo? Lets say you have downloaded an addon that adds some gameplay feature, how is that called, or rather how does the game recognize the addon and execute the change or addition ingame? This is a very simplistic explanation that may not be completely correct but should give you an idea of what an addon does. Here are good reference points in the Biki: 6thSense.eu:CG and modules Essentially an addon "patches" the content of the game by overwriting classes and/or their properties or adding new classes to one of the available root classes such as CfgWeapons, CfgVehicles, etc. It does this by "patching" the game configs. When the game start it extracts all of the relevant pbos to form the game config that contains all the properties the game needs to know about content that it needs to run. If you have a mod installed it also extracts info from the mod to further "patch" the game. If you want to get new content into the game, you have to patch the configs to do so. To focus on getting scripts in game via an addon, I have never done what [GLT]Myke describes. You might be able to just create the following folder structure: @MYADDON --Addons ----MYADDON -----$PBOPREFIX$ -----script1.sqf -----script2.sqf Then make the MYADDON folder into a pbo and then install it like any other mod. Then in game if you execute "\MYADDON\script1.sqf" it might work. Or, you might need to add a config.cpp to get the addon in game in which case you would need a config.cpp like this inside MYADDON: class CfgPatches { class MYADDON { units[] = {}; weapons[] = {}; requiredVersion = 1.10; requiredAddons[] = {}; }; }; and then you just execute them as described above The links above will show you how to introduce new sounds, models, vehicles, etc. To get an addon to execute a script automatically (either at initialization or after some other event) you use the config to patch in event handlers. This is where extended event handlers come in so handy so you do not overwrite other event handlers in the vanilla content or added by other mods. See my example here to see how to do that I hope that helps. Share this post Link to post Share on other sites
humvee28 10 Posted October 19, 2011 Thats alot of useful Stuff what i´ve looked for too. Thanks for posting this! :) Share this post Link to post Share on other sites