Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2018, 01:32 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 79,251
Dinocanid is on a distinguished road
Default Dialogue/choice branch system

Have you ever wanted to add a CYOA (choose your own adventure) game to your site? Maybe you wanted to make a quiz or some sort of branching dialogue? Well, this will help you do that. Here's how it looks in action:
  Spoiler: gif image 

The dialogue doesn't match up, it's a test after all x3
The second button doesn't lead to anything, so clicking on it does nothing.


-Pros-
  • No refresh abuse! If a user refreshes the page, it resets from the beginning. If a user presses the back button, it goes back to the previous page rather than the previous choice. No more cheating for multiple prizes!
  • No Javascript (does this count as a pro?)
  • Contained in a single function/page!

-Cons-
  • Keeping track of which choices lead to what can get confusing after a while. Be sure to leave plenty of comments for yourself so you don't get lost!

-The Process-
How this basically works is using multiple forms and buttons to link to each other and show different content depending on what choice you pick. For example...
PHP Code:
//choice handling
                
if($mysidia->input->post("left")){
                    
$document->add(new Comment("You went left!"));        
                    return;
                }
                elseif(
$mysidia->input->post("right")){
                    
$document->add(new Comment("You went right!"));                     
                    return;
                    
                }
//handling end

//adventure start
                
$document->add(new Comment("This is the start of your adventure! What will you do?</br>"));
                
$startForm = new FormBuilder("startform""pagename""post");
                    
$startForm->buildButton("Go left!""left""submit");
                    
$startForm->buildButton("Go right!""right""submit");
                    
$document->add($startForm); 
Doesn't that look nice and simple? Let's break it down piece-by-piece.
"choice handling" is where all of the following choices and such go. It always goes above "adventure start"! If you want to have a choice lead to yet another branch, then simply add a form within one of the statements. So...
PHP Code:
if($mysidia->input->post("left")){ 
                    
$document->add(new Comment("You went left! Now what?"));
       
$leftForm = new FormBuilder("leftform""pagename""post"); 
                    
$leftForm->buildButton("Go to the lake""lake""submit"); 
                    
$leftForm->buildButton("Go back home""home""submit"); 
                    
$document->add($leftForm);
                    return; 
                } 
if(
$mysidia->input->post("lake")){ 
                    
$document->add(new Comment("You went to the lake."));
                    return; 
                }
if(
$mysidia->input->post("home")){ 
                    
$document->add(new Comment("You decided to return home.<p><a href='pagename'>The End!</a></p>"));
                    return; 
                } 
Even though the choice handling always goes above the start, the order of the choices doesn't matter as far as I know. Just go with whatever order works best for you!
Since this purely uses PHP, you are free to use conditions, use database info, use variables, etc. For example, what if the user could only do this once a day? You could make a column in the database that holds whether or not the user has been on this adventure already. In whatever choice counts as a "dead end", update the database. That way, the user will be unable to do it again if they refresh or leave and return.
__________________
Reply With Quote
  #2  
Old 04-09-2018, 03:53 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 491,154
Hall of Famer is on a distinguished road
Default

This looks like a neat idea for whoever wishes to make an exploration/quest system on his/her adoptables site, good job with the tutorial.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:12 PM.

Currently Active Users: 690 (0 members and 690 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636