![]() |
Merging Scripts?
Hi all,
I have almost zero knowledge of C# scripting but by examining the various examples found around these parts I've been able to analyse them and reverse engineer them somewhat to use them in my missions. One thing I would like to do is to take parts from different scripts and merge them into a single script. However, my knowledge of the syntax in non-existent. Can anybody give a brief outline on how to merge two or more scripts please? And a big thanks to those out there who produce scripts for us, especially the ones who provide well commented code. It can make all the difference for noobs like me. Thanks again for any help. WB. |
Interesting question...so now we wait :D
|
In Short.... Yes you can merge scripts as long as you use just one class and public or private void. so you have to stip out the meat and merge it with a current script.
or you can try and take your 2 scripts and put the data from both inder each public/private void. To get you started here is a basic list that you could use to merge your codes under. Code:
|
Quote:
|
yes it's possible- but it can be frustrating- you really need to learn a little about coding (in my experience- I knew nothing when CoD came out but have had to learn how to cut and paste/write very simple stuff to run campaigns(offline))
http://www.csharp-station.com/Tutorial/CSharp/Lesson01 might be a good start- first 7 chapters will stand you in good stead. DON'T try doing this with windows notepad- get visual express or at the least notepad++. The ability to see the pairs of brackets is invaluable. This was the thing that really foxed me at first. The line numbering is also rather useful to see where the error is WHEN you get it wrong. CoD's fmb compiler at lest gives you the line/character where the error lies Make sure any variables used have been declared- these are the bits usually at top of code Code:
public class Mission : AMission |
Thank you gentlemen for your replies. I have already installed Visual C# 2010 Express after following Kodiaks excellent tutorials at the top of this forum.
I've also started on the C# tutorials mentioned in the post by bolox above - great find. I have some experience of Pascal programming from almost 30 years ago!! so the concept of programming is not totally alien to me. All I need now is twice as many hours in a day so I can learn C# AND mission building in the FMB. Still, keeps me off the streets! :) Thanks again, WB. |
By way of example, how would I combine the following two scripts:
Code:
using System; Code:
using System; I think it should work but I'm still a little hazy on class declarations etc at the moment. Cheers, WB. |
Think of each class as a separate source file.
You can add between the class {}'s any function you want, just as you would on a source code. So, you can copy the OnTickGame function and paste it inside the other's file " public class Mission : AMission" and it will work. Your only worry should be: a) not have 2 functions with the same name (i.e. 2 OnTickGame's) b) call the functions that are not called by the game from your code (i.e. isAiControlledPlane ) |
All times are GMT. The time now is 09:33 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.