Jump to content
The Dark Mod Forums

Scripting GUIS


DeTeEff

Recommended Posts

Good Evening...!

 

Doin some scripting here...The goal is to add certain gui overlays and simultaneously destroy others.

 

It's easy to add them with

 

float overlayHandle = $player1.createOverlay( "guis/mygui.gui", 100 );

sys.wait(5);

$player1.destroyOverlay( overlayHandle );

 

 

But I'm not able to access the handle if I try to call it from another function. Is it possible to add the "float-definition" to

the top of the script to make it a global float?

Edited by Fieldmedic
Link to comment
Share on other sites

Sotha has become adept at this topic but, for now, you could checkout the Doom3world tutorial to supplement whatever is present in the wiki:

 

http://www.doom3world.org/phpbb2/viewtopic.php?t=3128

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Yes, you can create the float as a global with no value but I'm sure those globals are created before the map stuff is spawned so cannot access map entities. If you need to assign those values at map start this is what I suggest:

 


  •  
  • Declare the float as a global without value.
  • Create a function that assigns it the values
  • Do not call the script from main() or target it from worldspawn as it won't work.
  • Call the function at map start this way:
    • Create a lever in a blue room
    • Make it auto-open 1 and target a script caller that calls the function.

 

There may be a neater way but the above should be OK.

Link to comment
Share on other sites

I have created a lever that targets a light but nothing happens with auto_open 1 OR auto-open 1.

 

I've created a lever that targets a callscriptfunction that calls a script that drops some lines in the console, but I cannot see them, not even before compile. Is this a bad way of debuging maybe? Is the script run BEFORE everything else so the text is invisible?

Link to comment
Share on other sites

My apologies. I spoke from memory. The correct spawnarg is auto_open_time The value you assign it is the time in seconds before it operates whenever closed.

 

Try that and it should work. If you put the lever visibly near the player start you can check it works. Then move it to a blue room.

Link to comment
Share on other sites

My vision in clear words:

 

 

 

different syntax to put the GUIS into floaters

 

float hugo;

float bugo;

float rugo;

float arnold;

 

 

the function that Fidcal mentioned

void bla() // called from the mentioned lever in the blue room

{

hugo = $player1.createOverlay( "guis/hugo.gui", 100 );

bugo = $player1.createOverlay( "guis/bugo.gui", 101 );

rugo = $player1.createOverlay( "guis/rugo.gui", 102 );

arrow_blown = $player1.createOverlay( "guis/arnold.gui", 103 );

}

 

(I guess this tells the script that "hugo" is a GUI that origins from guis/hugo.gui, in layer 100)

 

THEN I would like to be able to draw these GUIS on the screen at various points, and also be able to delete others of them.

 

If I add one of these GUIS later. (I've tried both.)

 

arnold = $player1.createOverlay( "guis/arnold.gui", 102 );

 

OR JUST

 

$player1.createOverlay( "guis/arnold.gui", 102 );

 

the GUI is drawn, but if I then try to delete it by

 

$player1.destroyOverlay( arnold);

 

it just won't do.

 

I would love to have a scipting pro by my side here to help me out :wacko: This is an important part in my contest mission...

 

Another solution would be if I was able to INSTANTLY disable/destroy a GUI message in DarkRadiant. But to my knowledge when I trigger a atdm:gui_message entity, the message is shown the exact amount of time I've defined in the entity, and its impossible to kill it BEFORE the time runs out?

Link to comment
Share on other sites

I symphasise. Sorry I can't help much because I'm only learning script myself.

 

Once the gui code is running I doubt there is any current way to stop it.

 

If it is possible to create an ultra short display with no fade then you might try calling the script over and over and display it 20 times for half a second (instead of just once for 10 seconds.) Then you can stop calling it when you want it to end suddenly?

Link to comment
Share on other sites

Sotha has become adept at this topic but,

 

Just to correct, I don't know anything about these gui overlay thingies.

 

I don't really know how to accomplish the things you want (nor did I fully understand what you want to do and how it fails), but somehow I think a thread may help:

 

I used this in transaction:

 

void update_sleepcamera()
{
sys.threadname("aim_sleep_loop"); 	// Gives this thread the name "aim_loop6" so it can be killed later.
while (1)
{
	sys.trigger($sleep_anim_eye_focus); // keep Camera6 pointed at target_null_6
	sys.waitFrame(); 	// wait a frame before continuing
}
}

void player_goes_to_sleep()
{
sys.println("player to sleep running..");

$sleep_camera.activate($player1); // Switch view
thread update_sleepcamera();

sys.killthread("aim_sleep_loop");

 

See the things:

void update_sleepcamera()

It starts an infinite loop that is executed constantly.

And then later this is killed with the sys.killthread() command. From entirely different function!

 

Maybe you could start a thread which

puts gui on / puts gui off and repeats it ad infinitum but so fast the player can't see any difference.

And then when you kill the thread (from some totally different script), POOF, your gui is gone.

 

But yeah, it might be ugly. But maybe the thread could be used more intelligently.

 

EDIT: bah, nevermind, the thread is started and ended from the same script. Probably won't help. ZZzz.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

I think you're onto something here...the goal is to make an arrow on a gauge to flip according to where the player is in the level. It's a tension meter! :)

 

So when you are in an allowed place, the "low arrow" GUI shall be visible and when you enter a restricted area, the GUI shall be changed to the "high arrow". So basically it's all about creating one gui and kill another when the player trigger things...

 

 

I would like you to go through the syntax for a loop in the script, with me.

 

 

 

In Basic it was like

 

for bla 1 to 1000

ADD GUI

REMOVE GUI

next

 

or

 

DO

ADD GUI

KILL GUI

LOOP

 

And then some kind of device to kill the loop itself. I don't think it will be any distortion ingame, like flickering

Edited by Fieldmedic
Link to comment
Share on other sites

Ugh....for some reason it works now...

 

Sadly I cannot recollect what the fault was but in short, here is how to do it:

 

At first I tried to be smart and just add a background gauge, and then add/remove the arrows above this GUI.

But as I kept on messing up, I just created the images I needed, in this case three gauges with the arrows pointing towards what I wanted.

 

 

 

create the floaters:

 

float gauge_low

float gauge_high;

float gauge_blown;

 

 

then when the tension goes UP, to show the new GUI (this is a function triggered by a trigger box)

 

gauge_high = $player1.createOverlay( "guis/gauge_high.gui", 101 );

$player1.destroyOverlay( gauge_low );

 

this draws the gauge with the arrow pointing to HIGH and then destroys the gauge with the arrow pointing to LOW

 

Hopefully this will be the end of my scripting rampage for a while -_-

Link to comment
Share on other sites

The new expert has arrived.

 

Move along...

 

^_^

 

Good luck with your contest entry FM!

 

:)

 

I am thinking of just arbitrarily changing the contest due date further out because of how much more I perceive that you and Biker need to wrap up. (No idea on Jesps...)

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I must imply though, that an expert on tension gauges would be a very delicate position in the steam punk universe :rolleyes:

 

 

Push the date further?

 

My competition mind says "No way! a deadline is a deadline!"

 

My overworked body says "........oh lord, yes please!"

 

My overworked mind says "...................care for a soda?" (that's a complete yes)

 

So thats two positive-to-extension-thinkers towards one naysayer

 

So Yes, expand please ^_^

Link to comment
Share on other sites

  • 2 weeks later...

Sorry that I reply so late, but I was offline for two weeks:

 

@Fidcal: I always admire your "soltuions" for problems with scripting or code, in the way of "oh horror!". A lever that auto-opens just to trigger a script at map start? That's... nuts! Rube Goldberg Nuts! :o

 

If there is really something that is not yet setup when the main script function runs, then simply use waitFrame()! (If for some reason one frame is not enough, use it twice, or a loop and wait 10 frames).

 

@Fieldmedic:

 

I think you are thinking a bit too complicated - you do not need 3 different GUIs, one GUI with three elements would be enough. Make the elements windowDefs, and then add three named GUI events that toggle the different elements on/off.

 

Here is an example from the message GUI:

 

       // called when the time is over
       onNamedEvent doFadeOut
       {
               transition "parchment::matcolor" "1 1 1 1" "1 1 1 0" "1000";
               transition "message::forecolor" "0 0 0 1" "0 0 0 0" "1000";
       }

 

You can call named events from scripts like so:

 

       // call fade_out on the GUI
       $player1.callGui(gui, "doFadeOut");

 

(where "gui" is the float variable that holds the GUI).

 

This way you only need one GUI overlay, you can create it at map start, and never destroy it (only at map end auto-destroyed) and you can do various transactions between the states, like fading arrows out, in, or change color etc etc).

 

If you have one and the same arrow on different places, you can even make it move position slowly!

 

If you need help with that, please just PM me.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Om1n0u5 at Doom3world prototyped something like that in his Doom 3 Mod Wrathchild. It was all done in interactive Doom 3 monitors, using GUI buttons for conversation choices. There's probably a smoother way of implementing it, but he's gotten conversations working the best I've seen so far.

yay seuss crease touss dome in ouss nose tair

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Has anyone had any luck with textures from Polyhaven? Their OpenEXR normal maps seem too washed out and give incorrect shading in the engine.
      · 4 replies
    • datiswous

      I tried to upscale the TDM logo video. First try:

      briefing_video.mp4 You can test it ingame by making a copy of the core tdm_gui.mtr and place it in your-tdm-root/materials/ , then edit line 249 of that file into the location where you placed the new briefing.mp4 file.
      What I did was I extracted all the image files, then used Upscayl to upscale the images using General photo (Real-Esrgan) upscale setting and then turn it back into a video.
      I might have to crop it a bit, the logo looks smaller on screen (or maybe it's actually better this way?). My video editor turned it into a 16:9 video, which I think overal looks better than 1:1 video of original.
      · 1 reply
    • nbohr1more

      Trying to be productive on my down-time before Capcom releases Akuma and my son is constantly on my PC playing Street Fighter...
      · 1 reply
    • OrbWeaver

      Finally got round to publishing a tutorial on baking normal maps in Blender, since most of the ones we have are inaccessible or years out of date.
      · 2 replies
    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
×
×
  • Create New...