OFPEC Forum

OFPEC The Editing Center => Comments & Suggestions => Topic started by: .pablo. on 13 Feb 2004, 03:55:04

Title: looking for an old article
Post by: .pablo. on 13 Feb 2004, 03:55:04
i remember seeing an article in the editing depot that compared ofp's scripting language to C++.  i cant find it now, and my friend was curious to see it.  i think snYpir wrote it, but im not sure.

anyway, does anyone know where i can find it?  or was it deleted somehow?
Title: Re:looking for an old article
Post by: deaddog on 13 Feb 2004, 04:20:50
OFPs scripting language is nothing like C++.  It's more like BASIC.

It comes remotely close in the config.cpp files in the use of classes but OFP's version is vastly simplified.  But the config.cpp file is not the same as the scripts we write.
Title: Re:looking for an old article
Post by: Kuro on 13 Feb 2004, 05:54:36
Well,

i think the OFP script language is a mixture the basic concept is clearly C++ but some commandos make it look like BASIC. IMHO it is a mixture.
Title: Re:looking for an old article
Post by: Homefry31464 on 13 Feb 2004, 05:57:10
I think I remember this as well, but I thought the article had something to do with functions... Not sure though.
Title: Re:looking for an old article
Post by: toadlife on 13 Feb 2004, 10:31:12
OFP functions are like C. The tutorial on writing functions by SnYpir is what your looking for.

http://www.ofpec.com/editors/resource_view.php?id=126
http://www.ofpec.com/editors/resource_view.php?id=128

Title: Re:looking for an old article
Post by: .pablo. on 13 Feb 2004, 14:12:44
toadlife -- those links were the first ones i checked, but i remember the article specifically "translating" lines from ofp to c++

i tried searching google again and im pretty sure this is the one (it wasn't by snYpir):

http://ofpcinematic.operation-flashpoint.de/download/Cutscenes.doc

Quote
(Note 2) At the end there's a line of code that will let you watch the whole fight. This is the most powerful thing in scripting. You can simulate any C or Basic statement with this. IF-THEN, WHILE, FOR anything.
In this case I wait for either the prisoner or the three soviets to be killed before I end the scene.

? (Alive res_prisoner) && (Alive off2 or Alive off3 or Alive man4) : goto "fightloop"

In plain english this line means: IF (prisoner is alive) AND (one of more of the soviets are alive) keep watching.
This is actually a simulated WHILE loop in C/C++.

In C++ this would have been:

while (res_prisoner.Alive() && (off2.Alive() || off3.Alive() || man4.Alive())
  sleep(1);

FOR loops are also easy to make, but they need a bit of extra work. Let's say you want four magazines to someone's inventory. You could do something like this:

_magazines = 4
_count = 0

#forloop
? _count < _magazines : res_prisoner AddMagazine("AK74"); _count = _count + 1; goto "forloop"

In C++ this would have been:

for (int count = 0; count < magazines; ++count)
  res_prisoner.AddMagazine("AK74");

Although the script language does not look like the C/C++ language, it can do all the same basic operations, making it a very powerful tool.


thanks for all your help