refresh background-text | Hintergrund-Text erneuern

  • #1, by ChimonoTuesday, 25. March 2014, 15:08 11 years ago
    EN:
    Hi everyone,

    I am working with this engine since 4 month I guess. But I can't figured one think out:

    I am using the background-text for my main character quite often. I add to every object action for talk, take, look etc. (is there a much better solution for this?)
    My problem is, that I am using the background-text to say something for all action parts, so he can run freely around for a much smoother gameplay, instead the normal text variation without the display-as-background-function (the mouse disappear and we have to wait until the text is done). But (and yes I know this is a background text wink ) if I am using two actions (like "look at" and "take" ) one after another quickly, the second text will be not displayed.
    So how can I "stop" the first text to display the second text. Consider, that I want to include sound files for the text and this sound file has to be stopped also.

    Did everyone give me some advice to make a much smoother gameplay with the option to try all actions faster one by one?

    Maybe the cursor change to a big "X" to display, that no functions are available, as long as the main character speak. (All actions has to be blocked! And it has to be a option to cancel the current text with ESC or right mouse button.)

    Thx a lot for reading smile
    DE:
    Moin moin,

    Ich arbeite seit circa 4 Monaten mit der Visionaire Engine. Leider konnte ich folgendes Problem noch nicht beheben:

    Ich benutze den Hintergrund-Text für meinen Hauptcharakter sehr häufig, um für jedes Objekt einen Text für jede Aktion (wie reden, sehen, benutzen) auszugeben. (Gibt es eine Möglichkeit dies einfacher/schneller/übersichtlicher zu machen, als dies für jedes Objekt einzelnd zu definieren?). Mein Problem ist, dass ich den Hintergrund-Text statt den normalen Text benutzen möchte, damit man viel flüssiger das Spiel spielen kann. Ich möchte nicht, dass nach jeder Aktion die Maus verschwindet und man abwarten muss, bis der Text vollständig angezeigt wurde. Nur wenn ich nun zwei Aktionen schnell hintereinander ausführe, wird der zweite Text nicht angezeigt, da der erste Text noch nicht fertig ist. Wie kann ich nun erreichen, dass der zweite Text dennoch angezeigt wird? Beachte, dass ich auch eine Sprachausgabe einfügen möchte, diese dann auch unterbrochen bzw. erneuert werden muss.

    Hat irgendjemand Ratschläge für mich, sodass das Spiel flüssiger zu spielen ist, mit der Option schneller alle Aktionen bei den Objekten auszuprobieren?

    Vielleicht, dass die Maus zu einem großen "X" wird, dass anzeigt, dass solange keine weiteren Aktionen möglich sind. (Alle weiteren aktionen müssen dann natürlich geblockt werden bis der Text vorbei ist oder man den Text mit ESC oder rechter Maustaste abbricht)

    Danke fürs lesen smile

    Newbie

    8 Posts


  • #2, by afrlmeTuesday, 25. March 2014, 17:30 11 years ago
    background text is a background process; meaning that you can not affect in any way at all once you set it going. If you were to start the background text via a called by other action part, then maybe you could use the quit action part to kill the background text - this is a theoretical guess on my part as I've not tested it.

    * actually just tested it & it did not kill the background text.

    you could set a condition for when background text is being displayed & then reset condition afterwards... this way you can query when interacting with something that it can't be interacted with until the condition has been reset. You could also prevent people from clicking on objects, items, characters etc by hiding the cursor, starting a cut scene or adding a mini script to the left mouse button click setting.

    anyway here's what you could do for the background text & condition...
    if condition 'condition_name' is false
     change condition 'condition_name' to true
     display background text by character 'linked_character'
     pause for value sec/ms/min -- value being same as display text pause value
     change condition 'condition_name' to false
    end if
    


    According to the data structure, background texts can be skipped. But for some reason the skip text action part under miscellaneous does not kill background text. I have an idea though via the registerHookFunction & a custom function which will be accessible via the left mouse button settings. We check if active text is background text then we send it to another function along with a state value to tell the left mouse button that a background text is active then we can kill it by setting (VTextActive, false) - I think.

    Imperator

    7285 Posts

  • #3, by ChimonoTuesday, 25. March 2014, 18:08 11 years ago
    Thank you AFRLme for your reply.

    The background text & condition idea works; of course. I can add a mouse cursor change, so the player knows, that no actions are available. But it has still two weaknesses: I have to add this to all 4-5 actions per object. Like talk, look, push; a big time killer. And the player can still move, but he has still to wait until the text is done to try an other action for the object.

    So now its a bit better but not that smooth I like it to have wink

    Your second idea sounds good. I try to contact my coder to try this out. Maybe tomorrow I know a bit more wink

    Best regards
    Chimono

    Newbie

    8 Posts

  • #4, by afrlmeTuesday, 25. March 2014, 18:23 11 years ago
    it will be a plug & play script...
    still tweaking, but I have it working to a degree already wink

    Imperator

    7285 Posts

  • #5, by afrlmeTuesday, 25. March 2014, 18:57 11 years ago
    you can skip background text with left click as you would do with normally displayed text.

    this script is added inside of a new script in the script tab. set script as definition script inside of the properties tab.
    txt = {}
    txt["_temporary_"] = ""
    txt["state"] = 0
    
    function hText(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getBool(VTextBackground) then
      txt["state"] = 1
      txt["text"] = text
     end
     return false
    end
    
    function eText(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getBool(VTextBackground) then
      txt["state"] = 0
      txt["text"] = nil
     end
    end
    
    registerHookFunction("setTextPosition", "hText")
    registerEventHandler("textStopped", "eText")
    

    inside of the left mouse button start following action (via mouse properties tab of game tab) you need to create an execute a script action containing...
    if txt["state"] == 1 then txt["text"]:setValue(VTextActive, false) end
    

    This will of course quit the background text immediately, but will still make the player start walking to a new destination/command destination etc.

    The other thing you suggested would also be possible too. Check if background text belonging to current character is currently active & if so then if an object is beneath cursor then swap to a dummy command which could contain a not available cursor & then in textstopped function reset command back to default or back to default in mouse out.

    Just out of curiosity, what type of command interface are you using?

    * haha... actually what am I thinking? razz

    just include an execute a script action bit - I mentioned above - before the display text (background) action. you will still need to add the main script part mind!

    Imperator

    7285 Posts

  • #6, by ChimonoTuesday, 25. March 2014, 19:52 11 years ago
    Wow AFRLme, I am impressed!

    I just had to make one alignment: For some reason, if I use for example look on an object and take right after it, your script stop the current background-text but stop also the new background-text from the take command. I had to put an "pause for 100 ms" action between the execute your script and the new background-text. But now it works very well and YES it so sooo fluid and smooth to play. Now I can play much much faster and are able to try a lot of action fast one by one! Good job!

    I found just one little issue: If an other background-text (from an other character) is speaking in the background, his text stoped also, if I use a action command on a object. But it is not a big deal. I just have to change all other background-text to a "display speaker-text". This should be a workaround wink

    I guess a lot of people can use this script. Thank you very much for your interest and time. I am a bit speechless for your commitment! smile

    *Right now I am using the left mouse button to move around and use all action commands and the right mouse buttons to toggle between them. I guess I will change this in the near future.

    Newbie

    8 Posts

  • #7, by afrlmeTuesday, 25. March 2014, 22:05 11 years ago
    The script was very global, but can easily be modified so it only triggers on background texts spoken by the active character or a linked character if preferred.

    The command interface you are using is the Sam & Max one. Left click for interaction, right click to cycle commands. More information on currently available/possible control interfaces for Visionaire Studio can be found here.

    My commitment? I provide English support for Visionaire Studio, & I'm sorting out the documentation on the new wiki for the upcoming 4.0 release.

    Just a quick note: All the scripts I share will include a note block in them when I add them to the wiki, stating that if you use any of my scripts then in-game credit must be provided. Also my scripts are donation optional, meaning you can use them for free, but a donation would be much appreciated; if possible.

    here is the script index page containing a compiled list of scripts - sorted into difficulty level categories - created by myself, or people on the forum, as well as a list of exclusive Lua functions that come standard with Visionaire Studio. @ http://wiki.visionaire-tracker.net/wiki/Compiled_Index_of_Lu...

    Lee smile

    P.S: here is the updated main code block so it only triggers on background texts spoken by the current (playable) character.
    --[[
    Kill background text (current character) [v1] (25/02/2014)
    Written by AFRLme [Lee Clarke]
    -- + --
    alternatingfrequencies@hotmail.com | skype @ AFRLme
    -- + --
    This script is donation optional. In game credit is non-negotiable.
    You are free to: ¹ use it in your game(s). ² modify the script.
    Do not remove - or edit - this comment block.
    --]]
    
    -- * tables * --
    txt = {} -- create table
    txt["_temporary_"] = "" -- set table as temporary
    txt["state"] = 0 -- default state of text (0 = normal, 1 = background text)
    
    
    -- * on text displayed function * --
    function hText(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
      txt["state"] = 1 -- text is now background text
      txt["text"] = text --store the current text
     end
     return false -- prevent text from being repositioned
    end
    
    -- * on text end function * --
    function eText(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
      txt["state"] = 0 -- set state back to default value
      txt["text"] = nil -- clear text
     end
    end
    
    registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
    registerEventHandler("textStopped", "eText") -- event handler for text end
    

    Quick note: I have tested this by having a npc looping between multiple background texts at the same time as the current character was speaking. when I left clicked (I have the execute script part in the left mouse button actions) it kills the current characters text only.

    Imperator

    7285 Posts

  • #8, by ChimonoWednesday, 26. March 2014, 00:25 11 years ago
    Thank you for your tipps and advice!

    Your updated script looks very solid. And thank you for chare it for free. Certainly u get some donation for your work. As soon as possible wink

    Newbie

    8 Posts

  • #9, by afrlmeWednesday, 26. March 2014, 00:42 11 years ago
    No problem smile

    Imperator

    7285 Posts

  • #10, by constantinSaturday, 15. April 2017, 11:57 8 years ago
    is there a possibility to make this skript also work to kill narration background texts? 
    thank you.
    constantin

    Forum Fan

    167 Posts

  • #11, by sebastianSaturday, 15. April 2017, 12:28 8 years ago
    Narration text doesn't have an owner.... But because these texts are the only one which doesn't have an owner you could check it:

    This is the base script for killing several background texts from th wiki / AFRLme :

    --[[
    Kill background text (multiple options) [v3] (30/02/2014)
    Written by AFRLme [Lee Clarke]
    -- + --
    alternatingfrequencies@hotmail.com | skype @ AFRLme
    -- + --
    This script is donation optional. In game credit is non-negotiable.
    You are free to: ¹ use it in your game(s). ² modify the script.
    Do not remove - or edit - this comment block.
    --]]
     
    -- * tables * --
    txt = {} -- create table
    txt["_temporary_"] = "" -- set table as temporary
     
    -- * function which kills active background text (1 = all, 2 = all characters, 3 = current character) * --
    function killText(val)
     for i = table.maxn(txt), 1, -1 do 
      if val == 1 and txt[i]:getBool(VTextActive) then txt[i]:setValue(VTextActive, false) -- all background text
      elseif val == 2 and txt[i]:getBool(VTextActive) and txt[i]:getLink(VTextOwner):getId().tableId == eCharacters then txt[i]:setValue(VTextActive, false) -- all character background text
      elseif val == 3 and txt[i]:getBool(VTextActive) and txt[i]:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() then txt[i]:setValue(VTextActive, false); break -- current character background text
      end
     end
    end
     
    -- * on text display function * --
    function hText(text)
     if text:getBool(VTextBackground) then table.insert(txt, text) end
     -- * --
     return false -- prevent text from being repositioned
    end
     
    -- * function for text finished * --
    function eText(text)
     for i = table.maxn(txt), 1, -1 do if not txt[i]:getBool(VTextActive) then table.remove(txt, i) end end -- if text is inactive, remove from txt table
    end
     
    -- * event handlers * --
    registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
    registerEventHandler("textStopped", "eText") -- event handler for finished text

    you could then add an elseif val == 4 which checks if there is no owner of a current active text:

    elseif val == 4 and txt[i]:getBool(VTextActive)  and txt[i]:getLink(VTextOwner) == nil then txt[i]:setValue(VTextActive, false) -- kill texts with no owner/narration


    its untested and out of my head^^

    Thread Captain

    2346 Posts