Display Display Text

  • #1, by ice7Tuesday, 15. May 2018, 02:50 7 years ago
    Hi

    I would like to show a different message when the user clicks on a scene object with display text action.

    Could you please tell me how to show a different message using the display text action part.

    example:
    click once and say "The door locked"
    click a second time "I need to find a key"

    Thank you

    Newbie

    14 Posts


  • #2, by esmeraldaTuesday, 15. May 2018, 08:42 7 years ago
    Use conditions or values.

    If condition "already_clicked" is false
    display text "the door is locked"
    change condition "already_clicked" to true
    else
    display text "i need to find a key"
    end


    Key Killer

    533 Posts

  • #3, by ice7Tuesday, 15. May 2018, 10:11 7 years ago
    Hi

    Thanks for the reply.

    How would the conditions look if there was a third or forth change of text ?

    And could you show me a short example of how this would work using a value.

    Kind Regards

    Newbie

    14 Posts

  • #4, by riffmasterTuesday, 15. May 2018, 10:18 7 years ago
    maybe you could use something like this:

    define a condition "door_is_unlocked" as false
    define a value "examinations" as 1


    If condition "door_is_unlocked" is false
        if value "examinations" is 1
            display text "the door is locked"
        end
        if value "examinations" is 2
            display text "i need to find a key"
        end
        if value "examinations" is 3
            display text "the door is still locked"
        end
        if value "examinations" is 4
            display text "the door is STILL locked, nothing changed!"
        end
        if value "examinations" is > 4
            display text "i don't say anything more about this..."
        end
        change value "examinations" +1

    end

    Newbie

    26 Posts

  • #5, by esmeraldaTuesday, 15. May 2018, 10:39 7 years ago
    If you want more than two possible reactions I would recommend using values, not conditions. Like in the example of riffmaster, or in the pictiure below. (i called the value "times_clicked" and started with an initial value of 0)


    Key Killer

    533 Posts

  • #6, by ice7Tuesday, 15. May 2018, 11:03 7 years ago
    Thank you both for the detailed answers, I will test out both options, and see what works the best. smile

    Newbie

    14 Posts

  • #7, by afrlmeTuesday, 15. May 2018, 11:33 7 years ago
    By the way I believe it's also possible to do elseif query types now (in 5.x at least). When you create an if query action part there should be a "elseif" checkbox in the parameters. What this allows you to do is create a bunch of if or else based queries which only require you to add a single end if action part right at the end of the list.

    if value 'examine_door' is 0
     do something
    else if value 'examine_door' > 1
     do something else
    end if
    values 'examine_door' + 1

    It's similar to what riffmaster wrote but it's a little cleaner. Less action parts & it's safer because it's an if or based query.

    @esmeralda: the example of riffmaster is correct with the initial condition. If the door is locked then those things are said, but a value would be better now than a condition as you can have the door locked at value 0 & the door open at value 1 rather than needing conditions. The recent implementation that Simon made to the engine to allow values to be used for defining what is active/inactive will save a lot of time in the long run as we no longer need multiple conditions or combi-conditions anymore. I really like that I can use a single value to determine the state of multiple scene objects now.

    Imperator

    7285 Posts

  • #8, by esmeraldaTuesday, 15. May 2018, 14:25 7 years ago
    @esmeralda: the example of riffmaster is correct with the initial condition. If the door is locked then those things are said, but a value would be better now than a condition as you can have the door locked at value 0 & the door open at value 1 rather than needing conditions. The recent implementation that Simon made to the engine to allow values to be used for defining what is active/inactive will save a lot of time in the long run as we no longer need multiple conditions or combi-conditions anymore. I really like that I can use a single value to determine the state of multiple scene objects now.
    I was answering to ice7s question on how to do the if querry with conditions when there should be more than two text changes. Thats way easier to do with values. 
    Of course riffmasters example is correct, if you want to integrate the querry door locked - or not locked. (Apart from the initial door-locked-question it is basicly the same what I did in the screenshot. But I did the screenshot before I saw riffmasters answer, so I posted it anyway...)
    And yes, the addition to define which object is active by using values is great. I use it a lot. But if you change the active object (by condition or value) - in this case the door - you don't need to do the if querry in the command action because you would click on a different object.

    Key Killer

    533 Posts

  • #9, by afrlmeTuesday, 15. May 2018, 17:09 7 years ago
    locked > unlocked > open, unless you automatically have the character open the door upon unlocking.

    Imperator

    7285 Posts

  • #10, by ice7Wednesday, 16. May 2018, 03:26 7 years ago
    Thank you for the replies. I have been trying out all options.

    @AFRLme, The code you showed works for two different display text. Could you please show how to make your code work for 3 or more display text.

    I did try, however my code block did not work properly. See attached image.

    Regards

    Newbie

    14 Posts

  • #11, by esmeraldaWednesday, 16. May 2018, 08:41 7 years ago
    In the example in your screenshot is no option what the engine should do, when the value = 1. So the code stops there and none of your texts gets triggered. And you have two option what to do when the value is > 1 or >2. That doesn't work because a value >2 will allways also be >1, so the second if querry (>2) will never get triggerd. You could use = instead of >. 
    Only in the last querry you should use >= (equal or greater). Or just use else.

    If value "Examination" = 0
    display text1
    else if value "Examination" = 1
    display text 2
    else if value "Examination" = 2
    display text 3
    else                                                        (or:   else if value "Examination" >= 3 )
    display text 4
    end if
    set value "Examinateion" +1

    Key Killer

    533 Posts