Skip to main content

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

Yes I want it to loop automatically when they reach the end, and yes the card's script is coming from "on view do" from the beginning.

(1 edit) (+2)

A simple option (with one moderate drawback) is that you can put all of your game script inside of a while loop inside of the on view do event. Basically like this:

on view do
while 1
# your game stuff goes here
end
end

That should start it over from the beginning forever. The drawback is that we haven't given you an exit from the loop. If the game is totally done and you don't need to edit or test anything anymore then that might just work for you as it is.

If you're still editing and tweaking things you may need to stop the script (with the menu [Script > Stop]) though it will stop everything exactly where it is. That includes any dialogizer or puppeteer elements left hanging out on screen. 

If you do need to do a stop like that you can force those two modules to clean themselves up on the current card by using the Listener [ Decker > Listener ] by using dd.close[] and pt.clear[]. In the Listener you'll need to hit Shift+Enter to run your code. Just mentioning that in case you haven't used the Listener before.

If the narrative doesn't specifically need to loop you could alternatively just send people back out to the title card (if one exists) and have them click play again, or have a "start" button which hides itself while the game is playing and then appears again after the story is done.

But this is definitely the simple answer to get it to loop (best applied cautiously when your game is otherwise finished).

If you want to take a slightly different approach that allows you to set up the auto-loop while still being able to test a single playthrough yourself you could put your dialogizer script inside a different event handler: a new one we're making up. We'll call it "cutscene".

on view do 
while 1 
cutscene[] 
end 
end 
on cutscene do 
# your game stuff goes here
end

Doing it this allows you to have it autoplay on the main card whenever it experiences a view event, but you can also set up a button on a another behind-the-scenes (or temporarily) card which will let you run through your game inside the cutscene event one time, and then automatically return to the other card with the tester button on it. This might be more useful if you're not finished tweaking things yet.

This is what that  button script could look like:

on click do 
go[yourmaincard] 
deck.card.event["cutscene"] 
go["Back"] 
end

Though, of course, change the card name to whatever it's actually called. 

But I hope one of these options makes sense and works for what you're doing!

(+1)

Omg thank you so much for all the options and tips!!! The "while 1" trick is exactly what I'm looking for my project and everything else you mentioned is going to come in handy in the future. :D