Jump to content

Function: Mds_Creature_Icon


Rendril

Recommended Posts

[b]null[/b] mds_creature_icon(int|string $id, string $attributes);

Will echo an image icon of the creature matching the ID if it is valid otherwise it will give a missing creature message.

The image is echoed directly by the function, there is only a null value returned.
Since it is a direct echo rather than a string, your HTML code will need ot be wraped around it.

The paramter sent is the creature ID, not the CTC. It can be found under the creature in the creature menu.

Example:

HTML[code]
<form method="post" action="">
Enter CTC to see the creature's day of birth<br />
<input name="ctc" type="text" /><br />
<br />
<input name="submit" type="submit" value="Submit"/><br />
<br />
<font size="1px">*Copy from "CTC" to "MDC", not the entire code</font>
</form>
[/code]

Script
[code]
echo @content[0]; //show the html

if(isset(@input['submit']))//check that button was clicked
{
//get the creature data
@vc= mds_is_ctc(@input['ctc']);

//check whether ctc is va.lid
if(@vc)
{
@vb = strtoupper("b");//i'm lazy
//get birth timestamp
@vt = @vc["date" . @vb . "orn"];
//print the day the creature was born
echo "<hr />" . @vb . "orn on " . date("l", @vt) . "<br />";
//show creature icon
mds_creature_icon(@vc['id'], "id='creature'");
echo "<hr />";
}
else
{
echo "inva"."lid ctc supplied";
}
}
[/code]

Edited by Rendril
Link to comment
Share on other sites

  • Root Admin

function can be adjusted to return the path of the picture, but its risky because if not displayed image will remain active and will take up resources for nothing with a bad written script.

If you think of improvements or other info related to this that you might need, let me know.

Link to comment
Share on other sites

Rather than returning the image path, it could return the unique hash for the image and the coder can append it to make an image path.
I think this would make the function more versatile.

Script execution time is limited to 5 seconds (and memory use is limited too), even a badly coded script will not be able to run indefinitely.
Perhaps limit the number of creature icons a script can gather in one session, like with avatars. 20 should be sufficient (1kb ?), pagination can be used when the coder needs more.

If the concern is the memory waste from a bad script, consider the additional load from the workaround to manipulate the image as desired. For example, wraping the image in an invisible div given a custom id to be accessed through js, the upside is this would all be done client side.


I admit the sample scripts I made are not optimal because I want them easier for a beginner to understand.
In most scripts I use explicitly declared variables to make the desired functionaly apparent, rather than annoymous parameters even though it is more efficient, I will change this if needed.


If you will keep it to echo the image, I suggest adding a transparent mask to prevent the image being saved easily. Allowing the coder to send an extra parameter for the image attributes as a string (id, class, style etc) would be useful too.
Unfortuantely the save protection cannot be enforced if the function is changed to return only the unique hash.

Link to comment
Share on other sites

  • Root Admin

you cant save the image easy, try it.

what i am more concerned of is that if a bad written script generates hashes for images that are not displayed (so the has gets released) it will cause trouble for other hashes that might collide. I will add the return parameter and update it, so that those that know what to do with it will use it.

Link to comment
Share on other sites

I was able to save the images without any difficulty.

I realise now why the image must get used quickly.
Thinking about its use, I see that it will need to be written as an image before the new icon function call, so instead can we be able to send more parameters to the image? It would be very useful to have id and class.

So a function call like this
mds_creature_icon(id, image_attributes);

For example:[code]
mds_creature_icon(12345, "id='image1' class='icon'");[/code]

Link to comment
Share on other sites

  • Root Admin

Yeah, i must admit i was wrong about an aspect of the protection. It tottaly fails in front of mozilla save media feature, BUT its purpose was and still is to restrict people from seeing in advance unreleased creatures and avatars, beat that :D


I will make the requested changes , consider function to be from now:

mds_creature_icon(12345, params);

the same for the avatar function

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...