Modding, Mission Design, and Coding > The Scripting Workshop
Advise needed for special effect.
Mobius:
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?
Nuke:
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: ---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)
--- End code ---
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.
Wanderer:
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...
Mobius:
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?
WMCoolmon:
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: ---$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
--- End code ---
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: --- elseif n_index == 3 then
drawSquadron("Logo 3", "SQUADRON NAME 3", "Kappa Wing, KIA in the nebula beyond Gamma Draconis")
--- End code ---
to get:
--- Code: --- 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
--- End code ---
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.)
Navigation
[0] Message Index
[#] Next page
Go to full version