Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+3)

I wrote a lot of script today. I felt a bit frustrated at times, there were some major oopsies (like accidentally creating 777 canvases. don't do that, it makes decker very slow LOL), in the end I managed to find a way to achieve roughly what I wanted (yay!) and that involved a lot of frantically browsing the decker community forums. Which I encourage you to do, a lot, especially when you're stuck.

I also used the chat contraption, it's very fun! I combined it with an invisible slider that counts the messages (or rather every click on the "next" button), so that things happen when you reach a certain message. It's easy to set up and it does cool stuff! Still have a bit more to do with the chat contraption/slider, but I am done for today.

(+3)

ooh, can you explain more about how you set up that chat contraption adaptation? 

(+2)

Sure, I'll try to explain my process :) long post incoming!

I'm using the chat contraption as a phone text app. Whenever the player clicks "next", a new message appears. That's cool! but I want my player to manually send the new messages on the right only. I want the messages on the left to appear on their own after a delay.

So I have a chat contraption called "chat1" and its corresponding button called "next". I added some lines in the "next" button script so that stuff happen. I'm sure there's a more compact way of doing this, but it works so I'm not complaining!

on click do
    play["click"]
    # show next chat
    chat1.next[]
    # add 1 to the counter (stored in slider)
    progress.value: progress.value+1
    # trigger the slider's "change" event
    progress.event["change" progress.value]
    view[]
end

As you can see in the button's script, I also have a slider called "progress". It starts at 0 and its Max is 17 (16 being the total number of messages in my chat contraption). You might want the slider be invisible in the final project (Widgets>Show None, & also Widgets>Locked, while you're at it).

My slider's script looks like this:

on change val do
    # call a "boop" event whenever the slider's "change" event is triggered
    scenePrologue.event["boop"]
end

I created a new event, "boop", that I use in the card level script to check on the phone conversation progress. "scenePrologue" is the current card's name. I'm not gonna show the whole card's script but I use something like this:

on boop do
    # check for chat convo completion
    if progress.value~1
        # increase value to avoid getting stuck in a loop
        progress.value: progress.value+1
        # pause to make the text message more realistic
        sleep[80]
        # show next chat
        chat1.next[]
    elseif ...
...

From there on, I had to match the slider's counter and the number of messages in my conversation so that all the messages on the left appear on their own after a delay, just like magic! :)

Of course you can use the counter to do something more than just revealing the next chat messages. You can use it to trigger a dialog for example, or to go to the next scene, just like this:

...
elseif progress.value~16
    progress.value: progress.value+1
    # fire next sequence
    eval[dialogStorage.widgets.script2.text () 1]
    pt.setup[deck sceneCafe
        "!show saya neutral offleft"
    ]
    go[sceneCafe "BoxIn"]
...

(if anything is unclear please don't hesitate to ask more questions.)

(+3)

A question - often I see chat contraption being done with a "prev" button too, if you do that, you'd want to move the slider backwards accordingly, right? Otherwise they'd get out of sync.

I'm also figuring you'd want to reset the slider to 0 when you go to the page, I think?

(+1)

In my case I don't have a "prev" button, so I didn't do anything specific to make that happen, but yeah that's definitely something you have to take into account if you want a "prev" button.

For now I have a "reset" button with a very simple script to manually set the slider to 0 whenever I want, while I'm still figuring out how to add more stuff. I don't know yet how I'm gonna replace that in the final project! :p

(+3)

ohhh very cool!!! ty for explaining

(+1)

No problem I hope that helps :))

(+2)

In context the approach you describe may offer more flexibility, but I'd like to point out for beginners that they could achieve a similar effect without creating any additional widgets by giving the "Next" button a script something like

on click do
    play["click"]
    chat1.next[]
    sleep[80]
    play["bloop"]
    chat1.next[]
    view[]
end

In general, straight-line code with some sleep[]s in the middle is a very powerful way of writing simple cutscenes.

(+3)

oh this is much easier for me (unhatched egg level programmer) !! thanks!! 

(+2)

Thanks for the clever addition! I guess Im an advanced beginner now? :3