Jump to content
Ding

Coding a Hatchery

Recommended Posts

Uhm, did i forgett to mention? As powerfull this script is, as timeconsuming and ressource hungry it might be. If you have x thousend dragons in your hatchery and NEVER added the time-of-death-date before it might take full cpu for several minutes for getting all the missing data. If your database is rather slow it might even take longer, all you can do ist wait.

 

http://dc.makegames.de/ takes about 10 seconds to run this script, but it runs every 10 minutes so there are only about 50-100 dragons per update. So pulling the data for 5000-10000 dragons will take up to 20 minutes in worst case.

Share this post


Link to post
Uhm, did i forgett to mention? As powerfull this script is, as timeconsuming and ressource hungry it might be. If you have x thousend dragons in your hatchery and NEVER added the time-of-death-date before it might take full cpu for several minutes for getting all the missing data. If your database is rather slow it might even take longer, all you can do ist wait.

 

http://dc.makegames.de/ takes about 10 seconds to run this script, but it runs every 10 minutes so there are only about 50-100 dragons per update. So pulling the data for 5000-10000 dragons will take up to 20 minutes in worst case.

your script works very good..

Share this post


Link to post

Um, what's the site that you use to make your Hatchery? I think I know how to code it, but i'm not sure how to actually make the site. (Also, i'v tried with Proboards but it just killed my Forum.)

Edited by Soruc The Dragon

Share this post


Link to post
Um, what's the site that you use to make your Hatchery? I think I know how to code it, but i'm not sure how to actually make the site. (Also, i'v tried with Proboards but it just killed my Forum.)

There is no specific site to coding a hatchery. All you need is a free or bought web host with PHP and MySQL functionality. x10hosting.com and 000webhost.com are pretty good. x10 is actually better. smile.gif

Share this post


Link to post

You can start with a free host, but realize that you may get asked to move (or simply shut down) if it starts getting too popular. However, it is a good place to start and to learn. That is how I originally learned to code. Eventually though, I needed to move to paid hosting due to increasing traffic.

Share this post


Link to post

I read the first page and didn't understand most of it. I've never really coded, but I would one day like to make a hatchery. Is there a simpler, more easier to understand method? Sorry for being a coding noob. xd.png

Share this post


Link to post

With learning to code, the only real way to learn is to do it and learn how to fix mistakes. It took me years to figure out code on my own, eventually multiple languages. Still, what is given on the first page is a start.

Share this post


Link to post

It won't make sense at first, but after practice, you'll be able to memorize all of the things that the code can do. Took me the whole summer to learn PHP. Took about 2 hours to learn that but about a month to understand what it all meant. You won't be able to do that much until you understand how it works... so yea. smile.gif

Share this post


Link to post

Glad to see this thread is still around and it's proving helpful to folks!

 

I have a bit of something to add, over on youtube there's a really nice channel called phpacademy, awesome tutorials and he's just uploaded a bunch of really basic ones to learn the beginning ins and outs of php. So things like echos, loops, if statements, etc.

 

 

http://www.youtube.com/user/phpacademy

 

I'll also stick this in the first post for a bit easier reference. Hope it helps!

 

 

Share this post


Link to post
I wasn't suggesting that page scraping was the only way, or the best way, it really all depends on what they are trying to do, and as to whether they want to use the API.

 

TJ does on occasion block sites from page scraping, trying to force them to use the API.

 

Once he blocks the ER I setup from page scraping, that is when I will withdraw all support and assistance to DC, and will consider it just another chapter finished. Kind of like when Boramir gets killed in the Lord of the Rings, we hear mention of him again from time to time, but no-one really cares, cos the character is dead.

Screen scraping is excessively expensive for the site being scraped, API access costs a lot less in bandwidth (which means money!).

 

TJ no doubt blocks screen scrapers for that reason. A site pulling thousands of pages a minute from him can cost him hundreds, maybe thousands of dollars a month!

Getting the same information through the API costs a fraction of that money.

Share this post


Link to post

Ok I am a bit confused I am good with php not API and I was wondering how to I display all the dragons a user has? I know the code to limit it to only dragons or eggs or hatchlings but I cant seem to get it to display anything but the last egg in the scroll has my code is

 

<?PHP

 $data = unserialize(file_get_contents("http://dragcave.net/api/XXXXXX/serialize/user/runiker"));
 foreach($data['errors'] as $error) {
 	if($error[0] == 3) {echo "Sorry, we were unable to find an dragon with that code."; return;}
 }
 $data = array_pop($data['dragons']);
 if($data['start'] == "0") echo "{$data['id']} is hidden!";
 elseif($data['hoursleft'] == -2) echo "{$data['id']} is dead!";
 else {
 	if($data['grow'] != "0") $type = "adult";
 	elseif($data['hatch'] != "0" && $data['hoursleft'] == -1) $type="frozen hatchling";
 	elseif($data['hatch'] != "0") $type="hatchling";
 	else $type="egg";
 	echo "{$data['id']} is a {$type} with {$data['clicks']} clicks, {$data['views']} views, and {$data['unique']} unique views.";
 }?>

Edited by Runiker

Share this post


Link to post

(disclaimer: I don't know web coding nor the API at all. If the error I'm pointing out is not really an error due to some funky thing with PHP, then ignore me please.)

 

foreach($data['errors'] as $error) {
 if($error[0] == 3) {echo "Sorry, we were unable to find an dragon with that code."; return;}
}   <-- this brace may be the culprit

 

The brace I've pointed out with the <-- closes the openbrace that's your foreach loop. The progam looks like it is walking through the entire loop, but the only thing to do inside the loop is check for error code of 3. The loop will either exit early because it found a 3, or finish without doing anything else.

 

I'm assuming from your note that all of the remaining logic is stuff you wanted to have happen for each and every dragon read. The problem is that the loop happened start-to-finish before reaching the code to run everything in that loop. So the code that's checking for various dragon-y stuff is going to run only once, for whatever entry was returned by array_pop(), and that's it.

 

Edited by WinstonGA

Share this post


Link to post

This is a bit pendantic and hokey, but I've reformatted the code chunk to exaggerate indents and nesting to show what I *think* is the logic that's actually executing. And I've added a couple of comments for my own use. Don't try to run this as-is, I have no idea if I've broken something.

 


$data = unserialize(file_get_contents("http://dragcave.net/api/XXXXXX/serialize/user/runiker"));
foreach($data['errors'] as $error)
{         // Start of foreach()
if($error[0] == 3)
   {
   echo "Sorry, we were unable to find an dragon with that code.";
   return;
   }
}        // End of foreach()


$data = array_pop($data['dragons']);

if($data['start'] == "0")
   echo "{$data['id']} is hidden!";
elseif($data['hoursleft'] == -2)
   echo "{$data['id']} is dead!";
else
{    // Start of else-we-can-see-it
   if($data['grow'] != "0")
       $type = "adult";
   elseif($data['hatch'] != "0" && $data['hoursleft'] == -1)
       $type="frozen hatchling";
   elseif($data['hatch'] != "0")
       $type="hatchling";
   else
       $type="egg";

   echo "{$data['id']} is a {$type} with {$data['clicks']} clicks, {$data['views']} views, and {$data['unique']} unique views.";
}    // End of else-we-can-see-it

 

 

Share this post


Link to post

ok well i tryed to modifyed them and didnt work. The code that repeats itself is checking for errors and only does the following code IF there IS an error not if not.

Share this post


Link to post

wow, I guess i will have to figure out how to code one of these for the proboards i mod for.

 

anyone got some base code for me to work with?

Share this post


Link to post

I have no idea where to post this but...

 

does anyone have an HTML code for an auto-hatchery? if so, can you reply and then PM it to me in code format? thanks!

 

(PLLLEEEASSEEE move if this is in the wrong place. thank you)

Share this post


Link to post

I'm good with HTML 'n all but I really never got to work with PhP..

So here's my site... (It's just a test, so don't judge it!)

http://dragonnest.ucoz.com/

the window to my hatchery won't work, it makes a new window and I can't figure out why. Here's my code:

 

<iframe id="er1" name="eraddz" src="http://www.jaemeia.net/er/er-entry.php" scrolling="auto" width="95%" height="125" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>
<iframe id="er2" name="erviewz" src="http://www.jaemeia.net/er/er-show.php" scrolling="auto" width="95%" height="525" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>
<iframe id="er3" name="erclickedz" src="" scrolling="auto" width="95%" height="400" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>

 

It's exactly as copied is it not? So how do I fix it?

Share this post


Link to post
I'm good with HTML 'n all but I really never got to work with PhP..

So here's my site... (It's just a test, so don't judge it!)

http://dragonnest.ucoz.com/

the window to my hatchery won't work, it makes a new window and I can't figure out why. Here's my code:

 

<iframe id="er1" name="eraddz" src="http://www.jaemeia.net/er/er-entry.php" scrolling="auto" width="95%" height="125" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>
<iframe id="er2" name="erviewz" src="http://www.jaemeia.net/er/er-show.php" scrolling="auto" width="95%" height="525" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>
<iframe id="er3" name="erclickedz" src="" scrolling="auto" width="95%" height="400" frameborder="1">
This page requires iframes. Please use a browser that supports it. We recommend Firefox.
</iframe>

 

It's exactly as copied is it not? So how do I fix it?

You're using Jaemeia's ER on your site. :3 Keep in mind that that doesn't make your site its own ER. You're simply embedding her site in yours via iframes.

 

Speaking of iframes, you're missing one. That's why new pages are being opened up. The links have target attributes with a value that doesn't exist. They are programmed to open in an iframe that you do not have on your page, so they open up in the new page instead, AKA "_blank".

 

On the page with all the codes, there's one that fixes this. It says "ER Click Page" in bold lettering. Beneath it, it even says "If you don't want clicking on the egg to go into a new window, then this next box will also be needed." So go back to Jaemeia's and grab that code. ^^

Edited by Chanilove

Share this post


Link to post
You're using Jaemeia's ER on your site. :3 Keep in mind that that doesn't make your site its own ER. You're simply embedding her site in yours via iframes.

 

Speaking of iframes, you're missing one. That's why new pages are being opened up. The links have target attributes with a value that doesn't exist. They are programmed to open in an iframe that you do not have on your page, so they open up in the new page instead, AKA "_blank".

 

On the page with all the codes, there's one that fixes this. It says "ER Click Page" in bold lettering. Beneath it, it even says "If you don't want clicking on the egg to go into a new window, then this next box will also be needed." So go back to Jaemeia's and grab that code. ^^

That's what I added below the ER, That's what the empty box is. I've seen Jaemeia's ER on someone elses site too and the viewer (Also below the er) wasn't working in the same way. It's like the iframes aren't relating to eachother?

Share this post


Link to post

http://dragcave.net/api.txt

(This a link to the API guide for when you want to set up your fansite to work with DC. This is all of course after you get access to the API key from TJ.)

Thank you! Since the forum limits search terms to 4 characters, finding information about the Dragon Cave API has been difficult.

Share this post


Link to post

Newbie question about the API access form:

 

Am I really supposed to supply an arbitrary private and public key myself? The methods I use to generate keys are not exactly URL friendly, not to mention I'm... not going to share a private key from a private/public key pair, as from my usual understanding of keys that should be entirely unnecessary as long as I supply a public one.

 

So... I'm guessing the terminology means something else? Is it really just two passwords? I struggle to interpret it as anything else at this point, but maybe someone who has a site with API access knows?

 

*feels like a right idiot*

Share this post


Link to post

  • Recently Browsing   0 members

    No registered users viewing this page.