Fyrd Argentus Posted March 16, 2011 Report Posted March 16, 2011 (edited) This is the condensed version of a conversation thread that I felt needed preserving. ============================= The real basics for beginners, before trying to understand the forum examples... Once you have clickie access via your 3rd wp, when you look at a clickie, you see a new button "edit own". Clicking on "edit own" you have 4 fields: Title, Password, Content, and Code. Normally a visitor sees everybody's work that has no password. These expire every 14 days, however, and become invisible (not gone) until they are refreshed. This is what is going on with the MDA books. If you put up a password (which must be unique to that clickie), then your work is visibile forever, but only to people who input your password. Each player has only one set of work per clickie. Thus, if you have something you want to post for a quest, I probably already have stuff most places for my own quest, but somebody like Apophys has a blank slate and an easier job posting something for you on a temporary basis. When the clock hits the top of the hour, all work in progress is flushed, so save often and watch the clock. Also, it has happened that the MD system has lost all clickie files. Archive everything you don't want to recreate. The title appears at the top of the viewer's screen automatically in special font. Note the author's name only appears if there are multiple authors and a list of choices to view (no password). If you put in NO CODE, then whatever is in the "content" section is just dumped to the viewer. If you put in code, then you must transfer anything from the content section over to the viewer bit by bit. The content is broken into blocks with a special LINE of characters which you must copy exactly between blocks. Then the blocks of content are called @content[0], @content[1], @content[2] and so forth and you use something like echo @content[3] to spit it out. However, each code statement is separated from the others by a ";" (this is number 2 source of bugs, forgetting the ";")and you must specify line breaks, so the actual code line probably would read echo @content[3]."<br>"; If and only if you have a code section, the first line of code must be the location statement copied from the header -- something like (locations 1_2x4_1) but no ";" needed. Unfortunately, this is just a hacker defense thing, and you must copy your clickie code in each location you want it to run - you can't just say multiple locations. The primary source of bugs is that any use of a reserved/function word inside a text is blocked, as a protection to the MD system. So you can't say for instance: echo "extend"; You must say: echo "ex"."tend"; ... wherein the single dot appends the two legal text fragments together. Three dots in a row is not legal, you must separate them with spaces. Etc. <br/> is line-break within a "content" section that is being echoed. "<br>" is what you would put in the echo statement inside code. Examples of conditional statements are: if( [s]condition [/s]){ [s]action1 [/s]; [s]action2 [/s]}; if( [s]condition [/s]){ [s]action1 [/s]} ELSE { [s]action2[/s];[s]action3[/s]}; ...where the struck through portions are code you write. For readabiliy, break this up on many lines and use indents, of course. Logical comparison operands are || for logical OR, && for logical AND, == for equivalence check (single "=" is "assign this value" operation, not check if equal), > and < work as expected. When you get to inputing data, realize that the whole page of code is executed including the input prompts and everything after them, and it does not wait for input. You must conceal the parts you're not ready to show with IF statements. When a player hits a button, putting something into your input variable, the entire page of code executes again. You must use the input value (originally == "" or null) and IF statements to then change which portions of your code execute or not on the second and subsequent passes through the code. Okay, with this much background, you can probably make more sense out of the forum section on MD Script. Go read! ========================= Apophys gave us code for his music player at Marind's Roundabout - it is his call if he wishes to share this here in the more public forum. ========================== Well, the line break thing is very confusing. Things don't work the way you expect, and MDScript is not html, it simply lets you dump html as content -- sometimes. I think php is closer to MD script than html is. Content does not behave the same if it is the default as opposed to being echoed. What I wrote above seems to have worked for me, after trying to wrestle with format for a long frustrating time. Try it sometime and check me. I am a pioneer-spirit here, not an expert. ================================== There are 3 ways I know to carry data from clickie-interaction to clickie-interaction. KEYS are things that are attached to a player profile. You have a key that says you defeated the willow guards, or have this or that piece of armor, etc. If you have done my quests, I have given you keys that say you have won each step. Any player that [can code and] knows the secret names I made up for them can read, or even change, the keys that I have assigned -- but only if [player with said key] visits [the coder's] clickie. ONE variable per coder/player combo may be saved by store(varname) and recovered by retrieve(varname). It just holds the last one you stuffed in there. I think you can save an array, but before I figured that out, I did a lot of clumsy work-arounds hashing multi-digit numbers to keep track of quests. This can't be accessed except by the coder/player combo that created it, but it is the same pigeonhole for all the different clickies involved. mds_storage functions are different, and I'm told that if you define a variable as "aoau" which means "all object all user", you can define and store any number of these. Then, they are linked only to your code, and don't depend on which user accesses the code. These can be arrays. There is a forum thread "Are there Global Variables?" that explalin their usage and I've been studying this and will try it very soon. Stay tuned. =================================== VonUngernSternberg wrote: Hi, I found a description of storage types here http://magicduel.inv...dpost__p__45805 The post talks also about some document that either has never been released or I'm not able to find it. =========================================== VonU's link was exactly what I needed to define any number of arrays, one to keep track of names of players in the "game", each one's position, and so forth. He asked the status of [my game-quest], so here goes.... 1. RL is pretty busy/stressful so my time is limited. 2. I consider it a necessity to interface this with the rest of my quest. I need to give some advantage or other to those who have completed that, and I'm still working on the storyline issues there. And why is this game being fought? I'm thinking 2 factions, but that's variable - you can do more than 2 sides in chess.... The first thing I will do is a storyline around the two factions, more background hints about what is going on, etc. leading up to an invitation to join in the game... 3. One prototype for the "chess-like" multiplayer game is based on a computer game called "Alice" where you race against the computer clicking in chess moves as quick as you can trying to take the enemy pieces, while it tries to take YOU (You take the role of Alice as the queen, and only piece, on her side). My vision is where you choose up sides, one piece per player, then everybody gets to move once per 24 hours. Do we start the battle before 16 register? Can players join in while the game is in progress? Is capture permanent, or just a reset? Do I use moves not present in normal chess? How does promotion work? 4. I'm confident all the data structures are there to do a "registration" and keep track of the moves. "Allowed" moves check will be tedious, but just mechanics. 5. The display is going to be a pain in several ways. I'm thinking that rather than using chess pieces, you use the player avatars (I think you can capture avatar ID's.... I use them in the fountain mirror, not totally sure you can store and use other times ... maybe I have to save pictures). You need some way then to indicate their ability (chess piece type) -- this might require a separate table simply listing such, or a picture frame. I may need the table anyway to update player registration status. I think you just echo the pictures, with line breaks every eighth avatar. Need a black and white "null" for empty spaces. You could draw an array of buttons using HTML - don't know if a button label can be a picture... This would make the "requested move entry" more elegant .... Can I reverse-image or something in vivid color with avatars to distinguish sides? Hmmm. So, the creative juices are bubbling during gaps in RL..... ======================================== Duxie helped VonU. with a technical query -- Duxie gives some very elegant java code for inputting buttons that VonU. got to work in MD Script -- I will leave it up to them if they want to copy it over here. My clumsy advice before Duxie showed how to do this was: The way MD script executes is pretty strange compared to what I grew up with [Fortran, Pascal, Basic, Snobol, Lisp, etc.]. It does NOT stop and wait for input. What it does is it paints the screen according to your code, lays out buttons and input fields and such, then it is finished and goes away. You paint the input button, but don't wait for input. When the user pushes any sort of "execute" button, then the text fields and radio buttons are captured, and the entire bleeding block of code runs again from the beginning. So, you have to use IF statements that look to see if the input string is still null to determine what to paint. You would then have to save the actual input into variables, repaint the screen, and so on, one pass through the code each time an input button is pressed. So Von, you just have 3 input fields, and do all the leg work in code behind the scene each time any one of the three is hit. Edited March 17, 2011 by Fyrd Argentus Brulant and Mighty Pirate 2 Quote
VonUngernSternberg Posted March 17, 2011 Report Posted March 17, 2011 Ok, so here is the part concerning the problem I proposed. ====================================== [...]I will try at least to explain roughly what I want to do. The example is the pillars at the GOE. There you type a string by clicking on the pillars. When this reaches a certain size, it is processed. In my case it would be enough to have two buttons, but the string must have an arbitrary length, so there must be a third button to append an end character and send the input to the MDscript. Let's say that two letters "a" & "b" are associated to the first two buttons and a "0" to the third,so that the output of the function has to be a string like "a0", "bab0", "bbbb0"..... This has to be passed to a MDscript variable then, because something will have to be stored at the end, to go on with the quest. [...] ======================================= Duxie provided a solution using a hidden button and javascript instructions, all I have done is taking his code and adapting it to MDscript ======================================= Good, it works exactly as I wanted to...had to do only a few minor tweaks, due to the MDscript restriction So, this is the html section: [php] <html> <body align="center"> <form name="main" action=" " method="post"> <span id="input_field"></span><BR> #<?php if (isset(@input['hidden_button'])) { ?><B>submited value=<?= @input['hidden_button'] ?></B><BR><?php } ?> <input name="button_a" type="button" value="A" onclick="addValue('a')"> <input name="button_b" type="button" value="B" onclick="addValue('b')"> <input name="button_c" type="button" value="C" onclick="addValue('c')"> <input name="button_0" type="submit" value="0" onclick="addValue('0')"> <input id="submit_value" name="hidden_button" type="hidden"> </form> <script> function addValue(value) { document.getElementById("input_field").innerHTML += value; if (value == "0") document.getElementById("submit_value").value = document.getElementById("input_field").innerHTML; } </script> </body> </html> [/php] and this is the php section for test: [php] echo @input['hidden_button']; echo @content['0']; [/php] These are the modifications: i) the action field is blank. There's no way to give a name to your document, and the only allowed action is that of loading the script again. ii) the php tag is ignored so it's commented and the command that displays the string is moved to the php section iii) the name of the hidden field has been changed to "hidden_button". Seems that every string containing "val" detected by the php interpreter gives an error. iv) access to normal php variables is not allowed so $_POST has been substituted by the proper form handler @input['hidden_button'] [...] Quote
apophys Posted March 17, 2011 Report Posted March 17, 2011 (edited) I have no problem sharing the music clicky. The clicky at Marind's Roundabout I put up ("Swimming Song" by Loudon Wainwright III) has this code for the MD Script section: [code](locations 1_-1x3_1) echo @content[0];[/code] and this in the content section: [code]<img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bT*xJmx*PTEyODAyMzkyNTA*MzYmcHQ9MTI4MDIzOTI1NjA3NSZwPTUzNTQxJmQ9bXAzcmFpZCZnPTEmbz1mNjQ*ZWIxNGFiMzM*/NzJjOTUxOTNjNTIxMmE1NGU4ZQ==.gif" /><div style='width:320px;text-align:center;background-color:dedede;font:normal 11px tahoma;height:16px;'>Loudon Wainwright III - Swimming Song | </a><a href='http://swim.yi.org/fav2/14.mp3' target='_blank' style='color:#3F4369;'> download</a> </div><object width='320' height='30'><param name='movie' value='http://images.mp3raid.com/i/mp3player.swf'><param name='flashvars' value='config=http://images.mp3raid.com/varext.php&file=http%3A%2F%2Fswim.yi.org%2Ffav2%2F14.mp3'><embed type='application/x-shockwave-flash' src='http://images.mp3raid.com/i/mp3player.swf' width='320' height='30' flashvars='config=http://images.mp3raid.com/varext.php&file=http%3A%2F%2Fswim.yi.org%2Ffav2%2F14.mp3'></embed></object><div style='width:320px;text-align:center;'><font style='font-size:10px;font-family:Tahoma;'>[/code] I took the player from mp3raid.com and changed the specifics to fit my needs. It's very nice due to its autoplay; the one I was using from airmp3.net did not autoplay. There are 3 places where the mp3 URL is placed, one for the download link and 2 for the player. Edited March 17, 2011 by apophys Quote
Fyrd Argentus Posted May 1, 2011 Author Report Posted May 1, 2011 (edited) Update on storage functions..... mds_storage_load and mds_storage_read are both rejected by the compiler, as they contain the reserve words "load" and "read" respectively. I have successfully implemented code to save a list of players and a data array associated with each as follows: @vo=mds_storage('[s]mysecretname[/s]','aoau'); The following is first-time call and sets up two npc's. It never had to be run again, so is turned to comments with //. //if(@storage[@vo]==null){ // @temp=array('name'=>'Herself','Team'=>3,'Power'=>15); // @storage[@vo]['The Queen']=@temp; // @temp=array('name'=>'Herself','Team'=>2,'Power'=>15); // @storage[@vo]['The Princess']=@temp; // }; The following is normal call to save a new name. @temp=array('name'=>uv('name'),'Team'=>@vt,'Power'=>@vv); @storage[@vo][uv('name')]=@temp; This is a call to reset myself so I can debug. @storage[@vo]['Fyrd Argentus']=null; This is a conditional statement for if the player is in the list or not if( @storage[@vo][uv('name')]==null ){ ---do one thing }else{ ---do something else }; This is the code for counting up power on each team. @vq=0;@vr=0;@vs=0; foreach(@storage[@vo] as @vl){ //note using @vl as the running index echo 'Fighting for '; if(@vl['Team']==2){ echo 'The Princess'; @vr=@vr+@vl['Power']; }else{ if(@vl['Team']==3){ echo 'The Queen'; @vq=@vq+@vl['Power']; } else { echo 'Balance in the Realm'; @vs=@vs+@vl['Power']; } }; echo ' with a power of '.@vl['Power']; echo ' is '.@vl['name'].'.<br>'; }; // Fin player list echo 'Score is '.@vq.' to '.@vr.' '.' with '.@vs.' neutral.<br>'; Edited May 1, 2011 by Fyrd Argentus Quote
Fyrd Argentus Posted May 12, 2011 Author Report Posted May 12, 2011 More on how arrays work combined with storage etc. Each clickie you must pull up (or initialize) the access code using something like: @vo=mds_storage('mysecretname','aoau'); Once ever you need to initialize the storage as being an array: if(@storage[@vo]==null){ @temp=array('name'=>uv('name')); @storage[@vo][uv('name')]=@temp; }; Each pass through the clickie's code (if you have inputs, it cycles through each time) you need to load from storage using something like: @temp=@storage[@vo][uv('name')]; If you use the code below to save data, it wipes out any data previously stored under user-name array @temp=array('name'=>uv('name'),'Team'=>@vt,'Power'=>@vv); @storage[@vo][uv('name')]=@temp; If you wish to add data to an existing array use this (it adds to, not overwrites, other array entries): @temp['newindexname]='datatextornumer'; @storage[@vo][uv('name')]=@temp; or directly @storage[@vo][uv('name')]['newindexname']='datatextornumer'; Also, remember to use the @storage call to save the data at the bottom of the code - if there is input and the clickie code recycles for another pass through the code, all the variable info is lost - you need to save at the bottom and reload it at the top. Quote
Fyrd Argentus Posted July 1, 2011 Author Report Posted July 1, 2011 (edited) Apostrophes in clickie titles... Use & then # then 39 then ; (five characters in a row - when I put it here, it turns into an apostrophe!) This is then interpreted as html. Thanks for the tip, Chewett. btw - chewett says use code tags in the forum, and it will let you spell such things out. That's [ followed by "code" then ] then the thing itself then [ followed [i][b]by / then again by code[/b][/i] and ] [sequence fixed per duxie below.] Edited July 3, 2011 by Fyrd Argentus Quote
duxie Posted July 2, 2011 Report Posted July 2, 2011 [quote name='Fyrd Argentus' timestamp='1309540562' post='86948'] Apostrophes in clickie titles... Use & then # then 39 then ; (five characters in a row - when I put it here, it turns into an apostrophe!) This is then interpreted as html. Thanks for the tip, Chewett. btw - chewett says use code tags in the forum, and it will let you spell such things out. That's [ followed by "code" then ] then the thing itself then [ followed again by code, then / and ] [/quote] [size="2"][font="Verdana"]about code thing: you can use "Code" style from drop down box at top left corner (near fonts, size). you can even mark a piece of text you want to make as code and then select that style btw slash thingie "/" must be right after "[" in closing tag part like in any other closing tag [/font][/size] Chewett 1 Quote
Fyrd Argentus Posted July 2, 2011 Author Report Posted July 2, 2011 (edited) [code]'[/code] Nope, still converts it to an apostrophe. &_#_3_9_; without the underscores. Edited July 2, 2011 by Fyrd Argentus Quote
Rendril Posted July 2, 2011 Report Posted July 2, 2011 This might come in handy for reference: http://www.w3schools.com/tags/ref_entities.asp There are also a number of useful tutorials on the site. Quote
The Warrior Posted July 30, 2011 Report Posted July 30, 2011 (edited) to write [code]'[/code] on the forum you have to write [code]&#39;[/code] Edited July 30, 2011 by The Warrior Quote
Fyrd Argentus Posted September 12, 2011 Author Report Posted September 12, 2011 (edited) I've learned some things from my memory-over-capacity fiasco, and my efforts to recreate data files from stored text files. Mostly you can read about the memory issues in the "questions" thread [url="http://magicduel.invisionzone.com/topic/10543-mds-storage-over-capacity/page__pid__91932#entry91932"]http://magicduel.invisionzone.com/topic/10543-mds-storage-over-capacity/page__pid__91932#entry91932[/url] if you are planning on creating a huge or dynamic datastorage file. Other items of interest: If you read a string in from @content, it seems to pad it front and back with spaces. You need to use the function trim(@vs) to strip off those spaces. Setting something = null does not make it not exist. null is apparently then stored in that space. What you have to do is copy a list including nulls over into a new list, checking item by item and NOT transfering the nulls over. Edited September 12, 2011 by Fyrd Argentus Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.