Skip to content
View in the app

A better way to browse. Learn more.

MagicDuel Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MD Script Manual

Offical threads that document MD script

  1. Started by Chewett,

    Copied From Murs initial Post (no code changed) Managing Content Sections In the content sections you put all text, stories, forms, templates, javascript and all things that are not MDScript code. Instead of putting all content in one big piece, you can separate it by placing a content separator, thats exactly this string: <!-- content separator --> All the pieces of content separated by such a separator, will be available for use in the MDScript under the @content array starting at index zero. Example: Content part 1 <!-- content separator --> Some other content <!-- content separator --> A template [[test]] with variables <!-- c…

    • 4 replies
    • 2.3k views
  2. Started by Chewett,

    This is only for official Manual posts and documentation Any new posts made will be moved to a more appropriate forum. Replies are allowed provided they are useful and ontopic

    • 0 replies
    • 1.6k views
  3. Started by Chewett,

    This MDScript language reference is OBSOLETE and kept for reference if needed for the future. DO NOT RELY ON THIS --------------------------------------------------------------------------------------------------------- MD Script v0.1 OBSOLETE, UPDATED VERSION WILL BE READY SOON. some things are in work, for example key checking is not working properly yet < Back MD Script allows you to add logic to your quests. Variables You may use variables to store values or do math functions within your script. These variables are restricted to a fixed number and predefiend naming. You may use the following variables as you like: var.a …

    • 0 replies
    • 1.4k views
  4. Started by Chewett,

    array mds_get_resource_count() Returns an associative array with the resources a user has in their inventory and the count. The returned format is: array(42) { 'Aromatic herbs' => int(98) 'Basic Iron Ingot' => int(4) 'Bones' => int(2) 'Branches' => int(109) 'Bushies' => int(50) 'Clay' => int(18) } If the user has no resources this will return an empty array. The keys are the resource name and the value is the number of resources.

    • 1 reply
    • 1.5k views
  5. Started by Chewett,

    Debugging Your Code Debugging is not some weird activity programmers do...well it is but if you want to do interesting things with MDScript you have to know about it. Seeing what is inside the variables you are working with is very important to understand what you should do with them next. Simple variables are easy to check, you just output them and see what value they have: print @va; (i usualy use 'echo' instead of 'print' , they do same thing, but print sounds easier to remember) Best practice is to put some other value next to the one you are looking for, so that if the variable is empty, you will see that and not just an empty page not knowing if…

  6. Copied From Murs initial Post (no code changed) How to Store values/variables using MDScript [php]//code in item A @vh = "wow thats simple"; store(@vh); //code in item B retrieve(@vh); echo @vh; //will output "wow thats simple" //can be used to store and load entire arrays of data.[/php]

  7. Started by Chewett,

    Here is a list of PHP functions avalible in MDScript: Below is the Initial Post Mur made: If anyone spots a possible abuse with any of the functions, let me know, i didnt checked ALL of them so i might have missed some with issues. //math 'abs','acos','acosh','asin','asinh','atan2','atan' ,'atanh','base_convert','bindec','ceil','cos','cosh', 'decbin','dechex','decoct','deg2rad','exp','expm1',' floor','fmod','getrandmax','hexdec','hypot','is_finite', 'is_infinite','is_nan','lcg_value','log10','log1p','log' ,'max','min','mt_getrandmax','mt_rand','mt_srand', 'octdec','pi','pow','rad2deg','rand','round','sin' ,'sinh','sqrt','srand','tan','tanh', //string 'print'…

    • 5 replies
    • 5.6k views
  8. Started by rikstar,

    I encountered this bug in MDscript, while I was working on a project myself. I needed to delete all my saved variable in @storage to start with a clean blank. So I did this: And I got the following warnings: Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 19 Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 24 Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 30 I was too lazy to use the good way to do it. The good …

    • 1 reply
    • 1.6k views
  9. Started by Chewett,

    It Is recommended that you read [topic='5494']Variables[/topic], Before reading this. Copied From Murs initial Post (no code changed) [b]User Vars[/b] Properties of the user accessing the script are available to the script. Don't worry, private info is not available to the script. Function to read user vars: [php]mds_read_uvars(var); uv(var);[/php] The uv() function is much shorter and easyer to use. What it does is actualy call the mds_read_uvars() function in turn. Parameters: var = a keyword that indicates what value you want to know about that player. Available vars: 'id' = player id 've' = vitality 'vp' = value points 'xpl' = exploring points …

  10. Started by Rendril,

    [b]int[/b] mds_location_visits(string $location) [b]Parameters[/b] $location can be 'current' or the coordinates of a location, for example '1_0x0_1'. [b]Returns[/b] Number of time player has been in the location. Will return null if the location does not exist. Example 1: [code] @vv = mds_location_visits('current'); echo "You have been here " .@vv ."times."; [/code] Example 2: [code] @vv = mds_location_visits('1_0x0_1'); echo "You have been to the Gazebo of Equilibrium " .@vv ."times."; [/code]

    • 1 reply
    • 1.6k views
  11. Started by Chewett,

    You can check the amount of times that a player has visited a location, This can be used to check if a player has visted certain locations if you are showing content that would be a spoiler if the user had not visited the location. This would be needed to comply with the new rules for MDscript. The function is: [code]mds_location_visits('1_0x1_1')[/code] If you assign that function to a variable you can use it to display the amount of visits for example [code] @va = mds_location_visits('1_0x1_1'); echo "Total visits here: " . @va; [/code] you can use any location id in the format as above, but you can also use 'current' to display the visits to the location…

    • 1 reply
    • 1.6k views
  12. Started by Maebius,

    Thank you Rendril! array|boolean mds_is_itc(string $itc) Returns false if invalid ITC is supplied, otherwise it returns an array with item information. ["id"] - The ID of the item itself. ["uid"] - The ID of the owner! ["playername"] - The playername of the owner ["name"] - The name of the object (ie: "Silver Coin") ["creationdate"] - When it was created (as epoch seconds I think?) ["transferdate"] - last transfer date (also as epoch secondS?) ["tag"] - Tag ("tool", "Valuable", "enchanted, consumable", etc) When inputting an item transfer code, never use the full string, it will be treated as invalid and return false. I find it best to copy from the ITC to MDI o…

  13. Started by Rendril,

    array|boolean mds_is_ctc(string $ctc) Returns false if invalid CTC is supplied, otherwise it returns an array with creature information. Returned array will have the following structure: ["id"] : creature ID ["uid"]: owner ID ["playername"]: owner Playername ["cid"]: creature type ["tokens"]: tokens held by creature ["dateBorn"]: timestamp when creature was created ["transfercount"] : number of transfers ["tradevalue"]: trade value ["customName"]: custom name of the creature, if any ["vitality"]: creature's maximum vitality ["level"] : creature's level ["experience"] : creature's experience ["battlesWon"] : number of battles won by creatre ["age"] : cre…

  14. Started by Chewett,

    Function mds_current_weather() This is used to get details on the current weather in MD Returns: boolean e.g. false //There is no weather currently in MD of note String e.g. "heavyrain" //Current weather in MD as a string Example: @va = mds_current_weather(); if(@va == false) { echo "there is no weather, boring"; }else{ echo "The weather currently is: " . @va; }

  15. Started by Maebius,

    I didn't see this on forum, but found it when searching Announcements for something unrelated. https://magicduel.com/page/Announcement/view/1506 It still works, I just tried it. :)

    • 0 replies
    • 1.8k views
  16. Started by Laphers,

    Copied from Mur's announcement You can now check if user has a specific item or not. The function mds_has_item("item name") returns the number of items the player has (zero if none). Because coins are technically also items, you can also check how much silver or gold someone has. This function will work the same way for upcoming raw material type of items (not planks and such, something else) Here is sample code: (locations 1_3x0_1) @va = mds_has_item("Silver coin"); echo "You have ".@va." Silver coins"; @va = mds_has_item("Mammon's Book"); if(@va>0){ echo "You have the book"; }else{ echo "Go search for Mammon's Book"; }

    • 3 replies
    • 2k views
  17. Started by Rendril,

    [b]array[/b] mdsi_item_heat(); [b]Returns[/b] -Amount of heat that has been stored in the item. -Players that have had heat stored in the item -How much heat each player has stored The return array is in this form: array(2) { ["current"] => total heat ["players"]=> array( ["player name"]=> heat stored by player, ["player name2"]=> heat stored by player, ["player name3"]=> heat stored by player, etc ) } } All the heat that has ever been stored will be returned. Later on heat might gradually decrease over time or be able to get retrieved through other functions. Example 1: [code] @va = mdsi_item_heat(); echo 'The box has ' . …

    • 2 replies
    • 1.8k views
  18. Started by Rendril,

    [b]void[/b] retrievetmp(variable $holder, [i]optional[/i] int $index) This function is an alias for [url="http://magicduel.invisionzone.com/topic/7584-function-mds-retrieve-sessdata/"]mds_retrieve_sessdata()[/url]

    • 0 replies
    • 1.5k views
  19. Started by Rendril,

    [b]void[/b] storetmp(string $value, [i]optional[/i] int $index) This function is an alias for [url="http://magicduel.invisionzone.com/topic/7583-function-mds-store-sessdata"]mds_store_sessdata()[/url]

    • 0 replies
    • 1.3k views
  20. Started by Rendril,

    [b]void[/b] mds_retrieve_sessdata(variable $holder, [i]optional[/i] int $index); [b]Parameters[/b] Holder is a variable that will be given the stored value. Index indicates which session box to retrieve from. There are 10 boxes, numbered 0 to 9. The default is 0. See the related function [url="http://magicduel.invisionzone.com/topic/7583-function-mds-store-sessdata"]mds_store_sessdata()[/url]. If you have stored a serialized value, you will need to unserialize it after retrieving. Example 1: [code] mds_store_sessdata('bakery', 2); mds_retrieve_sessdata(@vd, 2); //@vd now has 'bakery' [/code] Example 2: Unserializing [code] @vd = array( 've' => uv(…

    • 0 replies
    • 1.4k views
  21. Started by Rendril,

    [b]void[/b] mds_store_sessdata(string $value, [i]optional[/i] int $index); Stores temporary data for the player. There are 10 "boxes" for each player which you can work with to store data. Each player's session storage is unique to them, but each editor works on them independently. That means 2 different editors can store to index 1 but will not affect eachother. [b]Parameters[/b] The value is a string value that will be stored, to store other data types serialize it first. Index indicates which box to store it in, there are 10 boxes numbered 0 to 9. The default is 0. [quote]- stored data can be at most 200 chars long - it is valid only until the user logs ou…

    • 0 replies
    • 1.5k views
  22. Started by Rendril,

    [b]int[/b] mds_player_heat(); [b]Returns[/b] The player's active heat count. Example: [code] @va = mds_player_heat(); echo 'You currently have ' . @va ' active heat'; [/code]

    • 0 replies
    • 1.4k views
  23. Started by Rendril,

    [b]int[/b] mdsi_takeheat(int $heat); Takes heat from the player's active heat and stores it in the item. [b]Returns[/b] how much heat was taken. Amount to take must be positive. Can only take as much heat as what the player has, trying to take more will cause the player's heat to drop to 0 (currently) and will not store any in the item. Example: [code] @va = mdsi_takeheat(100); echo @va . ' heat was taken'; [/code] [i]The function is intended for item use only (hence the mdsi) but can be used in any clickable at present.[/i]

    • 0 replies
    • 1.6k views
  24. Started by Rendril,

    Scripts now require a location to be specified that they can be run from. Syntax is:[code] (locations coords)[/code] Where coords would be the user location, for example: [code](locations 1_0x0_1)[/code] This would limit the script to only being run fom the Gazebo of Equilibrium. Please note that string quotes are not used for the coords, that is, no " or '. Additional locations can be allowed to access a by seperating them with a comma, no spaces in between. For example: [code](locations 1_0x0_1,1_1x1_1,0_0x0_0)[/code] A maximum of 12 locations are allowed to be given access to a single script. The line can be placed anywhere in the script. Currently, v…

    • 0 replies
    • 1.8k views
  25. Started by Rendril,

    [b]null[/b] mds_player_avatar(string $name, string $attributes); Will echo the player's avatar image if the name is valid, otherwise it will give a no avatar message. Player name is not case sensitive. The image is echoed directly by the function with only a null value returned. The function can be called a maximum of 5 times in the script. Attributes are not required, but if used will be given directly to the image in html. Example: HTML [code] <script type="text/javascript"> function toggle(){ var img = document.getElementById("avatar"); img.style.display = img.style.display == "none" ? "inline" : "none"; } </script> <input type=…

    • 2 replies
    • 1.8k views

Member Statistics

  • 4582 Total Members
  • 936 Most Online
  • services Newest Member ·

Forum Statistics

  • Total Topics 17.5k
  • Total Posts 182.2k

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.