Expanding the 'Popup' text processor function.


Hi there! The Popup function added semi-recently is a neat little addition to the Text Processor's capabilities, an obvious application of it being to include information that, while not strictly relevant to a scene at hand, may be of interest to the player. Highlight a relevant word -- say, the name of a faction, or an item -- and when the player clicks on it, they get a popup window of the extended text, which they can close with a click.

{popup:text:long text} Displays a link, with the first text (which cannot have text processor directives nested in it). When the player clicks on the link, a pop-up will be displayed, containing the long text. The pop-up will disappear when the long text is clicked on. This can be used with the img command to have an image pop-up.

The issue I've run into, however, is that lack of ability to have further text processor directives nested within it. It's most obvious application runs into an immediate wall when faced with subjects the player will gain more in-game knowledge on throughout playing, which is why I sought to simply replace the 'long text' part with a string; say, something like {Codex.(name)}, which could be updated when the player made relevant progress. At the moment, printing variables in popups isn't possible -- they simply don't show up, not even as raw text.

I don't suppose anyone has an ideas on how to change this, if it's even possible with the current implementation? My original idea is still... possible, yes, but it would require that every single instance of a codex word would need a nested set of If checks after it, each filled with a variation of the codex passage, which would clog up things massively on the editor side and be far more hassle than it'd be worth.

In case I'm not being clear, here's how it works now;

{popup:Firearm:Firearms aren't as common these days, though an escalating arms situation before The End has resulted in several surviving caches being discovered and distributed today. A lack of ammunition, coupled with people's tendency to regenerate, has rendered them unpopular as anything more than clubs.}

Whereas what I'd like to extend it to is;


Wherein {Codex.Firearm} is a string I can edit whenever and wherever, automatically tied into every instance of the Firearm popup so I can edit them all at once on the fly.

That's odd; I'm looking at the code now, and I can't see any reason why {popup:Firearm:{Codex.Firearm}} wouldn't work.

Does it just display the command literally, or is there an error?

EDIT: Just tested it in one of my games, and it works fine. Can you provide a little more detail to help debug this? Maybe a sample game showing the problem?

I was going to say that the documentation only says you can't have text processor directives in the link text, and suggest how to fix that. But looking at the code, it looks to me like it should work fine.


This already works, I'm a big dummy who misread their own processing and placed the variable I wanted printed outside of the popup function and just didn't notice.

However, don't delete the topic, because that modification Angel posted might come in handy.


Ah… I made 2 silly mistakes.

Here's the function modified again, so that you can use text processor directives in the link text as well.
(Note that as it exists now, you could have {popup:{someobject.name}:{someobject.explanation}} and that will work fine. The limitation was actually that you can't have colons in the link text.

To fix that, change Split to Tsplit in this function:

  <function name="ProcessTextCommand_Popup" parameters="section, data" type="string"><![CDATA[
    section = Mid(section, 7)
    ary = Tsplit(section)
    s1 = StringListItem(ary, 0)
    list remove(ary, s1)
    s2 = Join (ary, ":")
    id = JSSafe(s1) + GetRandomInt(0, 999999999)
    link = game.defaultlinkforeground
    if (HasString(game, "altlinkforeground")) link = game.altlinkforeground
    s = "<span  style=\"cursor:pointer;color:" + link + ";\" onclick=\"$('#" + id + "').css('display', 'block');\">" + s1 + "</span><div id=\"" + id + "\" class=\"w3-theme-border\" style=\"position:fixed;z-index:9999;display:none;cursor:pointer;left:50px;top:40%;width:40%;background-color:" + game.defaultbackground + ";border:2px solid " + game.defaultforeground + ";color:" + link + ";border-radius:5px;padding:5px;\" onclick=\"$('#" + id + "').css('display', 'none');\"><p>"
    s = s + s2 + "</p></div>"
    return(ProcessTextSection(s, data))

This topic is now closed. Topics are closed after 60 days of inactivity.