DragonPrime Menu
Login
Resource Pages
Search
|
Show Posts
|
Pages: [1] 2 3 ... 18
|
8
|
Game Administration, Installation and Configuration / The Idea Place / Re: concerning the spelling bee
|
on: October 23, 2018, 12:16:12 AM
|
I'm only on my mobile so writing Code is a bit tough right now but I'll try to explain a little more // define an array with questions and answers. [ ] is like array( ) // this is placed at top of the run or run event function // answer is an array of arrays which contain a value and the correct index if it's the correct word $questions = [ [ 'question' => '`3What is it when you ask for help?`n`n', 'answers' => [['value' => 'assistance', 'correct' => 1], ['value' => 'assisstance']['value' => 'asisstance'], ['value' => 'asisstance']] ], ... ];
When asking the question $randomKey = e_rand(0, count($questions)-1); // get random question from array $question = $questions[$randomKey]; // print the question output($question['question']); $x = 1; //print and add navs for all answers in a random order foreach(shuffle($question['answers']) AS $answer) { output("`#$x)".$answer['value']."`n"); // all navs go to the same op // add the selected word and the randomkey to the navigation addnav("`b`G$x)".$answer['value']."`b","runmodule.php?module=spellingbee&op=check&key=$randomKey&word=".$answer['value']); $x++; }
And then just check if the 'correct' index is set for the 'word' and the 'key'. // when op is 'check' // get randomkey and selected word from navigation $key = httpget('key'); $word = httpget('word'); // get question from the question array $q = $questions[$key]; // run through all answers and check if the value is equal to the selected word from the navigation. If the word equals check if the correct index is set $right = false; foreach($q['answers'] AS $a) { if($a['value'] == $word && isset($a['correct']) { output("Yey, you're right!"); $right = true; } } // if the wrong value was selected if(!$right) { output("Aww, you're wrong!"); }
|
|
|
9
|
Game Administration, Installation and Configuration / The Idea Place / Re: concerning the spelling bee
|
on: October 21, 2018, 10:21:47 AM
|
Haven't really read your posts, just looked at those snippets. No matter if the array comes from a database or is static, it will be far easier to handle and extend than the way it's currently written in. What I was thinking of is something like this: I'll only write pseudo like code, so don't just copy&paste at the beginning of the run function $questions = [ [ 'question' => '`3What is it when you ask for help?`n`n', 'answers' => [['value' => 'assistance', 'correct' => 1], ['value' => 'assisstance']['value' => 'asisstance'], ['value' => 'asisstance']] ], ... ];
When asking the question $question = $question[$randomKey]; // get random question from array output($question['question']); $x = 1; foreach(shuffle($question['answers']) AS $answer) { output("`#$x)".$answer['value']."`n"); addnav("`b`G$x)".$answer['value']."`b","runmodule.php?module=spellingbee&op=jj68baef&key=$randomKey&word=".$answer['value']); $x++; }
And then just check if the 'correct' index is set for the 'word' and the 'key'. $key = httpget('key'); $word = httpget('word'); $q = $questions[$key]; foreach($q['answers'] AS $a) { if($a['value'] == $word && isset($a['correct']) { output("Yey, you're right!"); } }
|
|
|
11
|
Coding Support / Coding Support Desk / Re: Screenreader Accessibility??
|
on: May 05, 2018, 01:51:40 AM
|
Why would you want to create a superuser flag for that? Use a module pref, far more flexible and you don't have to mess around with the core files and it can be assigned to any user you want.
An please don*t use caps lock in your texts, no one wants to be shouted at.
|
|
|
12
|
Game Administration, Installation and Configuration / Installation and Configuration Assistance / Re: Upgrade 1.1.0 to 1.1.2
|
on: February 01, 2018, 12:13:43 AM
|
Not realy done this before, but this is about what I would do.
1. Export and Backup your live database and files 2. Import all (at least vital) information from the old database into the new one on your local test server 3. Inform your players that some recent progression (the last day or something) may be lost and that the site will go down for a couple of hours due to updating 4. Clean your server and upload your copy of 1.1.2 5. Run the installation process 6. Import your prepared local DB into the new live server
If your local DB is good enough prepared you might even skip installation and create the dbconnect manually.
Like I said that's only what I would do and there might be something missing which I'm not thinking about right now.
|
|
|
15
|
Coding Support / Coding Support Desk / Re: How To Convert Array Into String??
|
on: November 03, 2017, 10:03:29 AM
|
The one by Iori, for example, is using a debug function that seems to want an array but is getting a string. I did not code it. From Iori's module: $drop = get_module_objpref("creatures",$args['creatureid'],"drop"); debug($drop['name']); Seems the debug function wants an array...but $drop is expressed as a string here. So I want to take and explode $drop into an array...which ought to clear up the call stack. Well, it probably won't. Not the parameter of debug is the problem, but the called key ('name') of the array. Using explode will not magically give you an array with a key called 'name'. You should either just remove the call of debug, as it`s pretty unnecessary at that point or, better, check what ever is returned by the module object preference.
|
|
|
|
|
Support Us
No funds raised yet this year
Your help is greatly appreciated!
Who's Online
25 Guests, 0 Users
|