Author Topic: Advise needed for special effect.  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Advise needed for special effect.
I like the Scripting and its potential. Because it wasn't needed, however, I couldn't learn it well.

I had an idea that seems interesting, but I need some advise from anyone here that uses the Scripting system.

Basically, I want that one image and 3 texts of different dimensions appear in-game.

It should be something like this:

                                                           Screen
--------------------------------------------------------------------------------------------------------











Image(squadron logo)              SQUADRON NAME
                                                  small squadron description, something like(193rd Heavy Support Squadron of the AP 2nd Battlegroup, Aldebaran, APD Gryphus ecc.)



--------------------------------------------------------------------------------------------------------


I know that Scripting options have enough power to have something like this.

Question: 255 green parts of the image will be considered as transparent or not? Can I use different fonts and dimensions for the subtitles?
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Advise needed for special effect.
thats fairly easy to do actually. you need gr.drawImage and gr.drawString. id advise playing around with the draw functions in the hud hook, just to get used to them. what you want would only take a few calls to draw. more advanced stuff can be done with loops.

to draw that you would do something like this
Code: [Select]
tex = gr.loadTexture(inserttexturenamehere)  --gets a texture, change file name to what you want, you can also use an ani
header = "SQUADRON NAME"  --stores a string
body = "193rd Heavy Support Squadron of the AP 2nd Battlegroup, Aldebaran, APD Gryphus ecc."

gr.drawImage(tex,100, 600)  --this draws that image on screen
--note you could also use gr.drawMonochromeImage() if you want to colorize it like the com screen, just set color first

gr.setColor(150,150,255,200)  --this is a regular old rgb, this is light blue
drawString(header, 500, 600) 

gr.setColor(200,200,200,200)   --this one is light grey
drawString(body, 500, 600)


well thats how you draw it. you could probly make that a function if you plan to use it alot. its basic and will probly only look right at anything other than 1024 *768. if you just stick it in hud it will draw every frame. so youl want other code to tell it when to render.

as for green i dont think those rules apply. if you want transparency, use an image with alpha or draw monochrome after specifying a color with a < 255 alpha.
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 Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Advise needed for special effect.
Hmmm.. Wonder what happened to earlier campaign & player handles.. or even to campaign lib.. That is to say that before scripting rework we had those...

Campaign (cn) lib seems to be missing... i cant see any way any more to access the 'cmission handle'
Hmm.... ba.getCurrentPlayer() to access the current player handle with getName(), getCampaignName(), getImage(), getMainHall(), getSquadronName() seem to be missing too...
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Advise needed for special effect.
I'll try it. I want to get more involved...I like Scripting!

EDIT:
Question. I have to use many script-eval SEXPs or I can do it with just one script-eval?

EDIT2:
I get an error. I write "HellCats" instead of "SQUADRON NAME" and "Best AC Squad" instead of the description. FRED says that I should write numbers instead. What should I do?
« Last Edit: February 07, 2007, 05:41:23 pm by LieutenantGeneralMobius »
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Advise needed for special effect.
Nuke's code chunk shouldn't fit in FRED; there's a maximum of 32 characters for any string argument.

Your best bet is to define it as two functions like so in scripting.tbl:

Code: [Select]
$GameInit: [
drawSquadron = new function(n_texname, n_header, n_body)
tex = gr.loadTexture(n_texname)
header = n_header
body = n_body

gr.drawImage(tex,100, 600)

gr.setColor(150,150,255,200)
drawString(header, 500, 600) 

gr.setColor(200,200,200,200)
drawString(body, 500, 600)
end

drawSquadronIndex = new function(n_index)
if n_index == 1 then
drawSquadron("Logo", "SQUADRON NAME", "193rd Heavy Support Squadron of the AP 2nd Battlegroup, Aldebaran, APD Gryphus ecc.")
elseif n_index == 2 then
drawSquadron("Logo 2", "SQUADRON NAME 2", "194th Joker Interception Squadron of the Volition Bravos Battlegroup, Vasuda Prime, GTVA Collosus 37 ecc.")
end
end
]
#End

What this does is define two functions: drawSquadron(), and drawSquadronIndex(). drawSquadron() contains the code to draw the image, text, and whatever else is wanted for each squadron.

drawSquadronIndex() calls drawSquadron() with the squadron logo, the squadron name, and the squadron descriptive text. Only these squadrons will be accessible by FRED; if you wanted to add another, you would insert another pair of lines before the "end" just after the second drawSquadron() call in drawSquadronIndex(). You would add:

Code: [Select]
elseif n_index == 3 then
drawSquadron("Logo 3", "SQUADRON NAME 3", "Kappa Wing, KIA in the nebula beyond Gamma Draconis")

to get:

Code: [Select]
if n_index == 1 then
drawSquadron("Logo", "SQUADRON NAME", "193rd Heavy Support Squadron of the AP 2nd Battlegroup, Aldebaran, APD Gryphus ecc.")
elseif n_index == 2 then
drawSquadron("Logo 2", "SQUADRON NAME 2", "194th Joker Interception Squadron of the Volition Bravos Battlegroup, Vasuda Prime, GTVA Collosus 37 ecc.")
elseif n_index == 3 then
drawSquadron("Logo 3", "SQUADRON NAME 3", "Kappa Wing, KIA in the nebula beyond Gamma Draconis")
end

FRED

This way, in FRED you can say:

script-eval
-- drawSquadronIndex(1)

And it will output the first squadron. To display other squadrons you simply change the number, and this gets around the 32-character limit.

(DISCLAIMER: This example code is based on Nuke's example, and I just wrote this while taking a break from Java coding. So there may be some minor problems, but the overall code chunk should be correct.)
-C

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Advise needed for special effect.
ah cool. i really should play with sexps more. and yes my code was slapped together as a loose example, i didnt actually test it :D
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 Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Advise needed for special effect.
Ok

Is the 255 freen excluded, like in normal squad logos?


Stupid request: can you try to do it with FS2 squads and post a screenshot?
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Advise needed for special effect.
Ha-hem...
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Advise needed for special effect.
fs2squad-sct.tbm
Code: [Select]
#Global Hooks
$HUD: [
     gr.drawImage("squadimage", 25, 25);
]
#End
-C

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Advise needed for special effect.
This will exclude 255 green parts?
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Advise needed for special effect.
did you even read my first post
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 Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Advise needed for special effect.
I assume it does...
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Advise needed for special effect.
I'm not sure. I'm guessing it will, but all it comes down to is somebody's going to have to go ahead and try it to be sure. I'm not ignoring your question; it's just that it doesn't seem relevant because using scripting in anything is going to be far more involved than just trying out one or two builtin images. If trying that one thing is not feasible, then IMHO you should reconsider using the scripting system. Learning any kind of scripting or programming language requires time and above all, a willingness to learn and try things out. Especially for a language such as this, which is still in its relative childhood, where most of the information drifting around is theoretical.

Granted if I notice this thread when I have some free time (probably during the weekend) I will probably go ahead and try it myself just so I know for sure, and so I don't get accused of slacking off.
-C