PDA

View Full Version : Exploration System


AlexC
03-12-2012, 07:39 AM
Alright, so a while ago I took it upon myself to try and figure out a simple exploration script. Just something easy, where my members could look for items or pets, and I thought I'd share the script with you all.

The system is;

+ Non cheatable. Most people won't be able to figure out how to save at a certain point
+ Simple - very little coding is used. No huge thing to walk through.
+ Can be embedded in any layout
+ RANDOM - this is a non-narrated adventure.

So yeah, this actually wasn't very hard to make, the hardest part was finding a random link selector. I consider it rather easy to edit, but HOWEVER: there is a downfall to the easy to edit part - the "randomly selected" thing is included in the header of every individual page - I advise you mass edit, which I'll go over later.

LET'S GET TO IT SHALL WE?

So, to start, you'll need the page itself. Go and find your blank.php and copy it. Rename it whatever you want - for this, we'll go with "explore.php".

Between the "START SCRIPT" and "OUTPUT PAGE" things, place this:


$article_title = "Explore The Forest";
$article_content = "<div style='text-align:left;'>You have decided to take some of your pets exploring down in the park. It's a beautiful day and you'd just love an adventure right about now...</div><br /><br><iframe src='http://yoursite.com/explore/0.html' frameborder='0' height='400' width='700'></iframe> ";


Yeah, I know, everyone hates iframes - but guess what, in this case, iframes will help you so your members won't be able to save at a certain spot (say, on a rare pet link) and so you don't actually have to make a billion pages. You'll only need explore.php to actually be on your site, the rest is something else altogether (though it does involve pages).

Step two, is to change what it says up there. That's a copy of what's on my site and I'll be very upset if you don't change it. You'll want to change...

- Title ($article_title = "Explore The Forest")
- Content (You have decided to take some of your pets exploring down in the park. It's a beautiful day and you'd just love an adventure right about now...)
- Width (width='700')
- URL (http://yoursite.com/)

Step Three. Create a directory, folder or whatever your host is calling them. Call it something like "Explore" or "Explore Pages" - we'll just go with "Explore".

Step Four. Take this file below here and make a page titled "0.html" in your "Explore" folder.


<html>
<head>
<script type="text/javascript"><!--
var links = new Array();
links[0]="1.html";
links[1]="2.html";
links[2]="3.html";
links[3]="4.html";
links[4]="5.html";
links[5]="6.html";
links[6]="7.html";
links[7]="8.html";
links[8]="9.html";
links[9]="10.html";

function getRandomLink() {
var randomNum = Math.floor(Math.random()*links.length);
window.location = links[randomNum];
}
//--></script>
</head>

<body>

Insert little welcome message about how everyone is happy and the sun is shining, and ask which way they'd like to go.


<br><br><br><br><br>

<table border="0" align="center">
<tr align="center">
<td></td>
<td><form name="" action="">
<input type="button" value="Go Ahead!" onclick="getRandomLink()" />
</form></td>
<td></td>
</tr>
<tr>
<td><form name="" action="">
<input type="button" value="Go Left!" onclick="getRandomLink()" />
</form></td>
<td></td>
<td><form name="" action="">
<input type="button" value="Go Right!" onclick="getRandomLink()" />
</form></td>
</tr>
<tr align="center">
<td></td>
<td><form name="" action="">
<input type="button" value="Go Back!" onclick="getRandomLink()" />
</form></td>
<td></td>
</tr>
</table>

</body>
<html>

Alright, so this is going to be the starter page of your little explore system. Notice on the link list I don't have 0.html - means this page won't be repeated at all.

So, for the rest, you'll want to make ten copies of this 0.html page, and name them 1.html, 2.html, etc, etc. Then give each of them a different message. Most of them won't be much of anything - to increase the odds of getting certain messages, repeat them. So you can have nine messages about a weird looking flower and one about finding a rare pet under said flower.

And that's it! Almost.

Just a quick note that I said I would say; Mass editing. As you can see, the link selector is placed in the header of every single page. I wasn't sure how to put it in its own file (that'll be an update somewhere in the future). So if you plan to have fifty pages, I would recommend writing out fifty, pasting it into your ten and then just slowly making the pages afterwards, with the fifty links already in. Also, if you want to say, add ten or twenty pages in the future, don't do them one by one, do them all at once and add the links all at once. Tedious, I know, but hey - if you don't like it, don't use it.

So yeah, now I'm done. Hopefully it wasn't too confusing. Hopefully I can edit this over time and make it a little better. Credit would be nice - I didn't put it in the script anywhere, but maybe if you want to mention somewhere that Gloometh made the script, that'd be nice. If you've got an questions, suggestions, complaints, feel free to post them.

Nemesis
03-12-2012, 10:17 PM
If i find the time will try this.. good job though!

AlexC
03-12-2012, 10:23 PM
Thanks - it's a little time consuming to write out, but otherwise pretty easy.

mapleblade
03-13-2012, 02:41 AM
why not try PHP instead?

$random = rand(1,50);

if($random >1 && $random < 20){
$article_title = "You found a Rock";
$article_content = "You only found a rock, <a href="explore.php">Head on</a>";
// possible query, or -1 steps query
}
elseif($random =>21 && $random =< 40){
$article_title = "You found a Flower";
$article_content = "You only found a flower, <a href="explore.php">Head on</a>";
// possible query, or -1 steps query
}
elseif($random =>41 && $random =< 49){
// potion recieve query
$article_title = "You found a Potion";
$article_content = "You only found a potion, <a href="explore.php">Head on</a>";

}
elseif($random == 50){
// potion recieve query
$article_title = "You found a rare adoptable";
$article_content = "You found a rare adoptable hiding in the bushes, he seems to like you, and you take him home, it looks like his species is ADOPTABLE <a href="explore.php">Head on</a>";

}else{
$article_content = "Error";
$article_title = "There went something wrong.";
}


This will also stop spamming the page that u find an adoptable, since its not /1.html but all on the same page.

AlexC
03-13-2012, 08:33 AM
I don't know that much about php, so I can't really code form scratch...

mapleblade
03-13-2012, 09:05 AM
ah.. well my script shoud work if you want to use it :)

AlexC
03-13-2012, 10:45 AM
I'll stick with my version, because taking yours would mean I really didn't make it. Feel free to post yours though.

AndromedaKerova
12-06-2014, 03:23 PM
From what I can tell, it would generate pages saying something like "you found a pet/item/coin" and a link to continue exploring but I don't see how it would actually give people anything.

Also, in the blank.php I don't see anything to do with "START SCRIPT" and "OUTPUT PAGE"
Only:
<?php

class BlankController extends AppController{

public function __construct(){
parent::__construct();
}

public function index(){

}
}
?>

Kyttias
12-07-2014, 07:05 AM
This thread was made for an earlier version of Mysidia and pages are not rendered in the same way anymore.

I know that in 1.3.4 that for each page there are two: one to hold complex code, and one to render the page. It's helpful to bounce to a second file for complex code, especially when forms are involved. I don't actually know how to get around having two files, even though one is fundamentally going to be blank if it's useless to you.

Perhaps you can glean from my example:

I have map.php, and it contains merely this blank class (and the contents from blank.php work just as well, to base an example off of):
<?php

class MapController extends AppController{}

?>

And in the view folder, I have mapview.php:

<?php
class MapView extends View{

public function index(){
$document = $this->document;
$document->setTitle("Novul World Map");
$document->add(new Comment("<img name='NovuMap' src='http://fc01.deviantart.net/fs70/f/2014/308/9/d/map_small_by_kyttias-d85blb1.png' usemap='#M_NovuMap' style='border: 1px solid #ccc;'>"));
$document->add(new Comment('<map name="M_NovuMap">
<area alt="woods" title="" href="#" shape="poly" coords="224,39,246,70,215,130,174,135,153,115,157,88" />
<area alt="harbor" title="" href="#" shape="poly" coords="152,127,195,158,206,199,207,229,187,252,161,266,12 9,268,91,236,84,199,104,172,135,150" />
<area alt="maple thicket" title="" href="#" shape="poly" coords="78,259,143,289,140,314,143,335,128,358,91,376,51,3 47,43,300" />
<area alt="bay" title="" href="#" shape="poly" coords="150,330,183,346,227,327,230,276,205,241,173,267,14 9,282" />
<area alt="hills" title="" href="#" shape="poly" coords="219,244,263,214,304,221,335,264,286,309,240,310,23 6,274" />
<area alt="jungle" title="" href="#" shape="poly" coords="224,335,252,390,311,422,377,438,408,354,371,312,30 6,312,239,319" />
<area alt="marsh" title="" href="#" shape="poly" coords="249,399,276,423,256,485,225,489,138,478,84,426,102 ,403,120,395,118,382,136,363,188,395,226,403" />
<area alt="mangroves" title="" href="#" shape="poly" coords="319,438,296,467,302,492,425,493,427,465,415,441" />
<area alt="kelp forest" title="" href="#" shape="poly" coords="423,433,437,470,459,491,496,490,527,475,530,438,51 5,407,483,412,438,419" />
<area alt="plateau" title="" href="#" shape="poly" coords="430,362,473,406,507,391,519,378,525,343,502,295,46 6,292,433,303" />
<area alt="mountains" title="" href="#" shape="poly" coords="361,199,396,199,413,205,426,225,453,247,475,259,49 0,288,448,291,428,308,365,299,337,279,341,251,320, 217" />
<area alt="farmland" title="" href="#" shape="poly" coords="546,261,560,289,624,295,684,282,715,222,654,196" />
<area alt="beach" title="" href="#" shape="poly" coords="580,73,577,107,603,137,632,160,673,168,693,166,680 ,130,638,121,616,87" />
<area alt="plains" title="" href="#" shape="poly" coords="553,28,511,61,441,73,384,29,402,9,500,3" />
<area alt="desert" title="" href="#" shape="poly" coords="540,75,423,94,411,141,430,202,487,235,563,238,608, 204,593,142" />
<area alt="volcano" title="" href="#" shape="poly" coords="304,107,361,130,370,166,352,195,316,205,283,195,25 6,180,263,121" />
<area alt="brambles" title="" href="#" shape="poly" coords="279,11,266,49,279,90,315,102,369,99,406,61,385,38, 342,8" />
</map>
'));

} #end index
} #end MapView
?>


My page contains an image map (there's a couple of handy generators for this, here's one (http://www.image-maps.com/)). I don't have links associated with the locations yet, but you get the idea?

While this is not an exploration system in the sense that the original post has, I hope it explains how pages are rendered a little better? I'm trying to write up some vague documentation based on things I've learned about Mysidia, you can find that here (http://goo.gl/4TpzC5).

***

edit: And to imitate exactly what the original post has, try this--

explore.php:
<?php

class ExploreController extends AppController{}

?>

view/exploreview.php:
<?php
class ExploreView extends View{

public function index(){
$document = $this->document;

$document->setTitle("Exploring *Location*");
$document->add(new Comment("<div style='text-align:left;'>You have decided to take some of your pets exploring down in the park. It's a beautiful day and you'd just love an adventure right about now...</div><br /><br><iframe src='http://yoursite.com/explore/0.html' frameborder='0' height='400' width='700'></iframe>"));

} #end index
} #end ExploreView
?>

I can't particularly help you with the rest of it.

ilrak
12-07-2014, 11:13 AM
This is really helpful! I was looking for something similar (I've been trying to do an image map for shops and such). This is awesome! Thank you!

AndromedaKerova
12-07-2014, 02:42 PM
I believe, if I can figure it out, that the image map version will be useful. I was hoping to add more than one explore area with different pets and items.

Looks like it should be adaptable for shop maps too a little like Neopets has multiples on one map. ^_^

I'll give it a try when my brain can thing straight. Migraines are a real pain. XD

Thanks for updating the thread. <3