Author Topic: scripting.html  (Read 8507 times)

0 Members and 1 Guest are viewing this topic.

Offline Aginor

  • Spelljammer
  • 210
Hi guys!
Since the link in this thread http://www.hard-light.net/forums/index.php?topic=45554.0
to the scripting.html is dead, could one of you please create a scripting.html from a current build (doesn't have to be the newest one) and post it here?
I only have the WCS build and want to do a little bit of scripting, and unfortunately that build doesn't support the -output_scripting command line parameter it seems.
I know some of the newer features won't work but that doesn't matter, I suppose I'll only need some that are quite old for the scripts I want to test.

Thanks in advance!
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
You'll have to ask this in the WCS thread.

Further, the command line can be run by anybody on any build, so the recent RC's for 3.6.14 can output one.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
This is scripting.html as of July 2nd

http://blueplanet.fsmods.net/E/scripting.html

btw, you _do_ know that there's nothing preventing you from downloading an FSO build and running it?
« Last Edit: July 04, 2012, 02:00:20 pm by The E »
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Aginor

  • Spelljammer
  • 210
Thanks a lot, E!

About the FSO build... can it run without all the files? I don't have FS2 on my PC, just WCS (I can't even find my FS2 disks at the moment tbh).
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
It _should_ be able to run long enough to spit out scripting.html, anyway.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
You can always try running an FSO build on TBP (if you want to download it, that is. It's quite huge).

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
How about BtRL?  :)

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
It's too hard to find, I doubt any of the original download locations still has it.

 

Offline Aginor

  • Spelljammer
  • 210
Thanks to you guys I have now created my first scripts. :)
What I'm working on at the moment are two scripts to help me with the Strakha cloaking.

I already managed to read the player's ship class and I also can read and write HUD colors. I need that because I want to create the Wing Commander 3  cloaking thing as a script. I already managed to make most of the HUD black and white (except the colors of ships on the radar and the targeting brackets), and next I'll try if it is possible to make the rest happen.

Having some experience with programming/script languages helped me a lot, LUA really isn't hard. It is also quite pleasant sometimes, the syntax is quite easy.
But... I don't like that they decided to call an array "table", that confuses the hell out of me since I work with databases all day :D
And most important: WHO THE F*** thought it was a good idea to let arrays start with one? Fortran was that way and it sucked.

Whatever. It works and I'm now learning about all the objects and how they work.

What I don't understand yet is the hook structure, despite reading the tutorial.
I already got a scripting table that looks like this:
Code: [Select]
$Global hooks:

$GameInit
[
..  some methods that are used by Saga's HUD scripting
....
]

$HUD:
[
... triggers that use the functions defined above, for making the cool weapons display,
.....

....here I put my stuff that changes the color of all gauges depending on the ship type of the player (if playerShip.class == "Strakha#Inv") etc.

]
#End



Now I want to have that Conditional Hook thingie that triggers when there is a ship collision involving the player. Where do I put it? Everything I tried produced and error saying something like "#End expected" or just did nothing.
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
tables are different from arrays in that elements need not all be the same type. and the indexing starting at 1 is kind of an oddball thing, but you get used to it.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline m!m

  • 211
Now I want to have that Conditional Hook thingie that triggers when there is a ship collision involving the player. Where do I put it? Everything I tried produced and error saying something like "#End expected" or just did nothing.

If you want to know of collisions involving the player you can use this as a template:
Code: [Select]
#Conditional Hooks

$On Ship Collision:
[
if (hv.Self == hv.Player) then
    -- Add code that should be executed
end
]

#End

Inside that hook you have hv.Self as one ship that collided and hv.Ship as the other. I hope that helps.

 

Offline Aginor

  • Spelljammer
  • 210
Thanks m!m, but I already figured that out so far. As far as I have seen the object structure is pretty logical when you are used to OOP. What I don't get is where to put that block (starting with #Conditional Hooks and ending with #End).
Does it go into the same file (scripting.tbl), below the "#End" tag from the Global Hooks? I think I already tried that and the parser said something like "expecting <eof>, found Conditional Hooks".

tables are different from arrays in that elements need not all be the same type.
That's the same as PHP arrays.
« Last Edit: July 05, 2012, 06:18:18 am by Aginor »
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline m!m

  • 211
The #Conditional Hooks part should be located after the #End of the #Global Hooks part but you should consider switching to #Conditional Hooks entirely as that will give you much better control over when the hooks are executed and will make your live easier later.

tables are different from arrays in that elements need not all be the same type.
That's the same as PHP arrays.
I think the goal here is that lua "tables" aren't plain C arrays but can also be used as maps (like PHP arrays) so the term "array" could have been misleading.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
lua tables are pretty versatile. you can do named keys, use indexes, they can contain sub-tables or any of the other lua data types (including userdata and functions). so a table can do the job of arrays, structs, even objects if your lua fu is strong. note i come from a c/++ background (sort of), so i mean those terms from the perspective of those languages.
« Last Edit: July 05, 2012, 06:58:41 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Aginor

  • Spelljammer
  • 210
Yeah, it's really versatile, comparable to PHP. Of course it also shares its weaknesses it seems.
I am not a c or c++ expert (I use mainly script languages and Java) but I understand what you mean, those are also the terms I'm used to most.
A language that isn't strict with datatypes can be quite a shock when you come from a Java- or c background.
It certainly was my impression when I first used PHP. :D
But since I have experience using a couple of such languages already I'm fairly confident I'll get along with LUA quite well, provided a bit of training.
I just couldn't believe it when I saw that they used arrays starting with one. I thought that bad habit had finally died out. :D
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline Aginor

  • Spelljammer
  • 210
Found it.

I had to add

$Application: FS2_Open
$State: GS_STATE_GAME_PLAY

before the "$On Ship Collision:[]" block. I don't know exactly why but I read it in one of the examples and it worked :D
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
both of those are conditions that have to be met before the actions below them are executed. i dont know why we need the $application: condition at all since i doubt it would be anything but fs2_open unless they had decided to extend the scripting system to fred or whatever. but i find that ommitting it can lead to stuff not working. essentially what that says is:

if were running fs2_open and the state is GS_STATE_GAME_PLAY then run the following action scripts.

you can stack as many conditions as you want but they all have to be true before the actions are run. all available conditions and actions are listed in the scripting.html right at the top of the file. should probibly say that you probibly shouldnt use global or state hooks. global hooks can only run once, so if you are using modular scripting tables only the one from the first (or last, im not sure) *-sct.tbm will run. i guess they can be useful in tcs and whatnot where youre just using a scripting.tbl. as for state hooks they've mostly been deprecated, i think they were kind of an experimental feature that didnt pan out.

i kinda think the wiki entry for this needs work, i think what we have is left over from 3.6.9/10. its confusing and has a lot of useless or misleading information in it and is kinda vague where it matters.
« Last Edit: July 06, 2012, 06:22:42 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
There scripting.html form saga build

[attachment deleted by ninja]
May the Force be with you

 

Offline Aginor

  • Spelljammer
  • 210
?? How did you get that? When I added the command line option nothing happened at all...
Member of the Scooby Doo model Fanclub "verticies and splines are the medium and he is the artist."

 
were you running through the saga launcher? because the launcher removes all flags, also make sure you are adding it to the file in the user documents/Violation/data folder.
May the Force be with you