Jump to content
The Dark Mod Forums

Recommended Posts

Posted

There was an idea to add two features to GUI scripts (6164).


The first one is runScript command, which allows GUI script to call a function from game script.
Interestingly, this feature is already supported in the GUI engine, but the game code only processes this command when the player clicks left mouse button on the GUI (i.e. usually it works in onAction handler, but not in namedEvent or onTime handlers).

Obviously, ID initially did not envision runScript as a global feature which works the same way everywhere, their idea was that it is context-sensitive, and whoever calls the GUI code can then pull the commands generated by the call and do whatever he wants with them.
I'm not sure I really want to change this architecture...

Anyway: what are the possible use cases for runScript command?


The second feature is namedEvent command, which simply generates/calls a named event with specified name on the whole UI, which can be then handled by matching onNamedEvent handlers.

However, this command can be implemented in several ways:

  1. Whenever namedEvent command is executed, the named event is processed immediately. The rest of the script (after namedEvent command) is continued only after generated named event is fully processed.
  2. Whenever namedEvent command is executed, named event is put into some kind of queue, then the current script continues to execute. The generated named event is executed at some moment later, but surely on the current frame.
  3. The point 2 can be further differentiated on the exact order when generated named events are processed.

So the first approach is how functions normally behave in normal imperative languages, with a real call stack.
The second approach is delayed execution, like what we currently do with "resetTime X; -> X::onTime 0 {...}" combo (at least everywhere in the main menu GUI).

My worry with the first approach is that it is an major change for GUI engine with no past experience, and it will probably not match well with the long-established GUI wierdness (I mean e.g. the wierdness that all expressions in GUI script are executed before the script commands start executing).
And it would work different both from the "resetTime + onTime 0" combo.

On the other hand, the callGui in game scripts do execute named event immediately.
And I must admit nested GUI calls could be used to reduce the issues from the GUI weirdness mentioned above.

Also, this command exists in Quake 4, but I'm not sure how exactly it works.
And it's probably good idea to make TDM work the same way.

  • Like 4
Posted (edited)

These are my initial thoughts for possible use cases (copied from the linked bug tracker entry).

1) In the recent thread

@datiswous asked if it was possible to develop a template for an enhanced type of briefing where people could specify a different background for each page of text (possibly by having different xdata items for each page)
2) It would also make it easier to develop a in-game journal type of readable which is added to when the player does certain actions. A current example of this is done in the first mission (Monastery) of a House of Locked Secrets but the implementation is quite cumbersome because
a) Each xdata item contains the whole contents of the 'previous' xdata item plus the added text.
b) The in-game actions have to be performed in a pre-determined order.
3) Readables could be made more sophisticated e.g. having tabbed pages (e.g. in a paper address book).
4) You could have dynamic entity guis (e.g. destination displays at railway stations which change when the train has left).

I'm willing to expand on these if needed

Edited by boissiere
  • Like 2
  • Thanks 1
Posted (edited)

Nice knowing you are looking at this. :) 

Btw when I made my own version of "namedEvent" gui cmd, I just copied the convention of other gui cmds like the "localSound" cmd, what I found is that it made the usage of simple nameEvents in GUI's very fast, with no need to mess with c++ and compile the engine. I think exactly the same reason quake 4 developers said they implemented it, thou like you said we don't know how they made their version. 

Perhaps is why I had some issues with my implementation when trying to call more complex onNamedEvents, so is something that needs to be well tested.

Simple example of usage (the following code is untested and should be looked as "pseudo" code)

windowDef Desktop
{
	rect	0,0,640,480
	backcolor 0,0,0,1
	menugui 1
	
	float "text_state" 0
	
	onInit {
		// just in case ...
		if("Desktop::text_state" != 0) {
			set "Desktop::text_state" "0";
		}	
	}
	
	//*************** Events *************************
	onNamedEvent ClearText {
		set "Text::text" "";
		set "Desktop::text_state" "0";
	}
	
	onNamedEvent SetText {
		set "Text::text" "Hello world";
		set "Desktop::text_state" "1";
	}
	//************************************************
	
	
	windowDef Text
	{
		rect	240,41,165,110
		visible	1
		forecolor	1,1,1,1
		text	""
		textscale	0.5
		font	"fonts/micro"
		textalign	1
	}
	
	windowDef back_btn
	{
		rect (320-55),(240-35),50,30
		visible 1
		text	"Click Me"
		textalign 1
		textscale	0.3
		font	"fonts/an"
		
		
		onActionRelease {
			if("Desktop::text_state" == 1){
				namedEvent "ClearText";
			} else {
				namedEvent "SetText";
			}
		}
	}
}

 

Edited by HMart
Posted

  

23 hours ago, boissiere said:

These are my initial thoughts for possible use cases (copied from the linked bug tracker entry).

I guess I'll copy my answer too.

Quote

1) In the recent thread @datiswous asked if it was possible to develop a template for an enhanced type of briefing where people could specify a different background for each page of text (possibly by having different xdata items for each page)
2) It would also make it easier to develop a in-game journal type of readable which is added to when the player does certain actions. A current example of this is done in the first mission (Monastery) of a House of Locked Secrets but the implementation is quite cumbersome
3) Readables could be made more sophisticated e.g. having tabbed pages (e.g. in a paper address book).

I think all these use cases are blocked by the fact the TDM core readable scripts don't support them.

If you want to use TDM's readable code, then you have to respect its boundaries/interface. If it does not normally support something, then you can't do it while using them, regardless of what features GUI scripting or game scripting supports.


On the other hand, let's suppose someone is willing to implement a fully custom GUI + script, without support --- i.e. no readable.guicode, no xdata, etc.
In this case, he needs to put control logic somewhere.

Putting it both in GUI code and game scripts would generate confusion, bugs, and maybe even race conditions.
Putting it only on GUI side is bad simply because GUI scripting is bad.
The only viable solution is to put all the logic into game script.

But if all the logic is in game script, then GUI does not need the runScript command.
It should only set some of its own gui variables as "requests", so that later the game script could detect these requests and process them.
At least that's how TDM core readable support works.

Posted
15 hours ago, stgatilov said:

I think all these use cases are blocked by the fact the TDM core readable scripts don't support them.

If you want to use TDM's readable code, then you have to respect its boundaries/interface. If it does not normally support something, then you can't do it while using them, regardless of what features GUI scripting or game scripting supports.

Can someone override core readable scripts for their mission?

Posted
1 hour ago, datiswous said:

Can someone override core readable scripts for their mission?

It's funny you should ask that because I've been thinking about this a bit and am now wondering if my use cases 2 and 3 (more dynamic in-game readables) are actually possible with the existing system.

I'm not sure you would want to actually override the existing scripts but more likely add in new scripts into the existing system. I might have a go at at this weekend.

Posted
6 hours ago, datiswous said:

Can someone override core readable scripts for their mission?

You can probably write a new one, and use it in your readables.
If you override existing one, the next change in core will break your mission.

The only question is: is there any hardcoded stuff in C++ connected to readables?

  • 1 month later...
Posted

I rather regret that the namedEvent and runScript ideas were put in the same bugtracker request, since they each clearly justify their own topic.

From the discussion above, it seems that namedEvent would be easier/safer to implement this round.

It appears runScript is more problematic, and furthermore, may not be the only or best way to implement new capabilities for readables. The latter (e.g., tabs, different backdrops for different pages) probably also needs a separate bugtracker item.

Turning to namedEvent...

@stgatilov in the OP was wondering about whether the in-GUI call to namedEvent should be synchronous (i.e., happen immediately) or asynchronous. Synchronous is easier for the script writer to think about, and would be my preference. As he indicates, this would be less like other gui script aspects (some of them "weird"), but more like calls to gui named events from doomscript. And, by introducing nested call stacks, he thinks may provide future opportunities for reduction in weirdness.

It is unclear to me if HMart's implementation is synchronous or asynchronous.

Probably we should not worry about whether this usage is consistent with Quake 4, since we'll probably never know.

Posted
On 12/5/2023 at 6:53 PM, Geep said:

It is unclear to me if HMart's implementation is synchronous or asynchronous.

My implementation is just a simple gui script cmd, is very naive and just follows the same system of other existing gui script cmds, made by idSoftware.

I have zero idea if is synchronous or asynchronous that is beyond my expertise, nor if it is the same as done in Quake 4.

Plus like I said above I do remember experiencing some small problems with it, when trying to use it to call more complex namedEvent's, that may be connected to the "synchronous or asynchronous" stuff.

  • Like 1

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

    • datiswous

      I moved from Manjaro Linux (rolling release) to Linux Mint (LTS). One of the reasons was that I found the updates a bit too often and long. But now on Mint I get updates every day, although they're usually small updates.
      · 3 replies
    • JackFarmer

      "Hidden Hands: Vitalic Fever" - new update available including subtitles & compressed briefing video (thanks to @datiswous) and several fixes.
      · 0 replies
    • Wolfmond

      🇬🇧

      2025-04-20
      I'd like to track my level design progress a bit more often now, so I'm using the feed in my profile here.
      I've been working intensively on Springheel's YouTube course over the past few days. I'm currently up to lesson 8. There is so much information that needs to be processed and practiced. 
      I have started to create my own house. As I don't have the imagination to create a good floor plan, I grabbed a floor plan generator from Watabou and experimented with it. I chose a floor plan that I will modify slightly, but at least I now have an initial idea. 
      I used two guards as a measuring tape: The rooms are two guards high. It turned out that I can simply double the number of boxes in DarkRadiant in grid size 8 that are drawn in the floor plan. 
      I practiced the simplest things on the floor plan first. Drawing walls, cutting walls, inserting doors, cutting out frames, creating VisPortals, furnishing rooms.
      I have had my first success in creating a book. Creating a book was easier than I thought. I have a few ideas with books. The level I'm creating will be more or less a chill level, just for me, where I'll try out a few things. I don't have an idea for my own mission yet. I want to start small first.
      For the cellar, I wanted to have a second entrance, which should be on the outside. I'm fascinated by these basement doors from the USA, I think they're called Bilco basement doors. They are very unusual in Germany, but this type of access is sometimes used for deliveries to restaurants etc., where barrels can be rolled or lifted into the cellar. 
      I used two Hatch Doors, but they got completely disoriented after turning. I have since got them reasonably tamed. It's not perfect, but it's acceptable. 
      In the cellar today I experimented with a trap door that leads to a shaft system. The rooms aren't practically finished yet, but I want to continue working on the floor plan for now. I'll be starting on the upper floor very soon.

      __________________________________________________________________________________
      🇩🇪

      2025-04-20

      Ich möchte nun mal öfters ein bisschen meinen Werdegang beim Leveldesign tracken, dazu nutze ich hier den Feed in meinem Profil.
      Ich habe mich in den vergangenen Tagen intensiv mit dem Youtube-Kurs von Springheel beschäftigt. Aktuell bin ich bis zu Lektion 8 gekommen. Das sind so viele Informationen, die erstmal verarbeitet werden wollen und trainiert werden wollen. 

      Ich habe mich daran gemacht, ein eigenes Haus zu erstellen. Da mir die Fantasie fehlt, einen guten Raumplan zu erstellen, habe ich mir einen Grundrissgenerator von Watabou geschnappt und damit experimentiert. Ich habe mich für einen Grundriss entschieden, den ich noch leicht abwandeln werde, aber zumindest habe ich nun eine erste Idee. 

      Als Maßband habe ich zwei Wächter genommen: Die Räume sind zwei Wächter hoch. Es hat sich herausgestellt, dass ich in DarkRadiant in Gittergröße 8 einfach die doppelte Anzahl an Kästchen übernehmen kann, die im Grundriss eingezeichnet sind. 

      Ich habe bei dem Grundriss erstmal die einfachsten Sachen geübt. Wände ziehen, Wände zerschneiden, Türen einsetzen, Zargen herausschneiden, VisPortals erstellen, Räume einrichten.

      Ich habe erste Erfolge mit einem Buch gehabt. Das Erstellen eines Buchs ging leichter als gedacht. Ich habe ein paar Ideen mit Bücher. Das Level, das ich gerade erstelle, wird mehr oder weniger ein Chill-Level, einfach nur für mich, bei dem ich ein paar Sachen ausprobieren werde. Ich habe noch keine Idee für eine eigene Mission. Ich möchte erst einmal klein anfangen.

      Beim Keller wollte ich gerne einen zweiten Zugang haben, der sich außen befinden soll. Mich faszinieren diese Kellertüren aus den USA, Bilco basement doors heißen die, glaube ich. Diese sind in Deutschland sehr unüblich, diese Art von Zugängen gibt es aber manchmal zur Anlieferung bei Restaurants etc., wo Fässer dann in den Keller gerollt oder gehoben werden können. 
      Ich habe zwei Hatch Doors verwendet, die allerdings nach dem Drehen vollkommen aus dem Ruder liefen. Inzwischen habe ich sie einigermaßen gebändigt bekommen. Es ist nicht perfekt, aber annehmbar. 
      Im Keller habe ich heute mit einer Falltür experimentiert, die zu einem Schachtsystem führt. Die Räume sind noch quasi nicht eingerichtet, aber ich möchte erstmal am Grundriss weiterarbeiten. In Kürze fange ich das Obergeschoss an.



      · 2 replies
    • JackFarmer

      On a lighter note, thanks to my cat-like reflexes, my superior puzzle skills and my perfect memory, I was able to beat the remastered version of "Tomb Raider: The Last Revelation" in a new superhuman record time of 23 h : 35 m, worship me!
      · 3 replies
    • Goblin of Akenash

      My mapping discord if anyone is interested, its more of a general modding thing rather than just for TDM 
      https://discord.gg/T4Jt4DdmUb

       
      · 0 replies
×
×
  • Create New...