Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Interactive Lessons (https://forums.graalonline.com/forums/showthread.php?t=69205)

Twinny 10-06-2006 07:31 PM

Interactive Lessons
 
I've started to make GS2 lessons which will could become available on servers in the form of interactive GUI's which display information, give questions/feedback as well as practical lessons. It's just an idea i've had and I'd like to know if it is actually a decent idea before i sit down and map out a few lessons. below is my first basic lesson on objects (Information may be slightly incorrect but i'm sure Skyld will kick me if i give wrong information).

Lesson Base
PHP Code:

/* Lesson 1 : Objects */
//#CLIENTSIDE
function onWeaponFired()
  
showLesson();

public function 
showLesson()
{
  new 
GuiWindowCtrl("Lesson1Window")
  {
    
profile       "GuiBlueWindowProfile";
    
extent        "450 300";
    
position      "5 5";
    
text          "Lesson 1 : Learn About Objects. By Twinny";
    
destroyonhide true;
    
canmaximize   false;
    
canresize     false;
  
    new 
GuiTextCtrl("Lesson1Title")
    {
      
profile "GuiBlueTextProfile";
      
position "30 25";
      
profile.fontsize 40;
      
text "Brief Lesson on Objects!";
    }
    
    new 
GuiScrollCtrl("Lesson1Scroll") {
      
profile       "GuiBlueScrollProfile";
      
position      "15 75";
      
extent        "420 200";
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
visible    true;
      
canmove    true;
    
      new 
GuiMLTextCtrl("Lesson1Body") {
        
useownprofile true;
        
profile       "GuiBlueScrollProfile";
        
position      "5 5";
        
extent        "400 180";
     }
    }
      
  }
  
graalControl.addControl(Lesson1Window);
  
setLesson();


Actual lesson
PHP Code:

function setLesson()
{
  
Lesson1Body.settext(
  
"Welcome to Twinny's basic lesson about objects!" NL
  
"Graal is made up of objects. Some examples include players, levels,
  weapons, horses, bombs and gui controls." 
NL "" NL
  
  
"An object is made up of variables, functions and other objects.
  Let's take a look at a few variables, objects and functions found in a level." 
NL "" NL
  
  
"Some Functions" NL
  
"function objecttype()" NL
  
"function findareanpcs()" NL
  
"function getmappartfile()" NL
  
"function tiletype()" NL "" NL
  
  
"Some Objects" NL
  
"arrows = TGraalVar;" NL
  
"bombs = TGraalVar;" NL
  
"chests = TGraalVar;" NL
  
"compus = TGraalVar;" NL
  
"horses = TGraalVar;" NL "" NL
  
  
"Some Variables" NL
  
"isnopkzone = 0;" NL
  
"issparringzone = 0;" NL
  
"name = graalcitybank_inside_01.nw;" NL
  
"nopkzone = 0;" NL
  
"tilelayercount = 1;" NL
  
"tiles = 0;" NL
  
"timeout = 0;" NL
  
"width = 64;" NL "" NL

  
"The function used to make that will become available in lesson 2
  GS2 allows for intereaction with objects. For example:
  player.chat = level.name;. This will make the player say the levels name" 
NL "" NL
  
  
"You can also access custom functions using objects. Eg. player.customfunction();" NL
  
"You can also access the object itself using this eg. this.x = 40" NL "" NL
  
  
"This is just a brief example of what will no doubt become alot more clearer.
  Hopefully this wasn't too hard to understand. If not - mail me at [email protected]
NL
  
"Next lesson: Advanced Objects with a few practical based lessons"
);    


Very basic with no interactive material. Do not judge / vote on that exact lesson but moreso on the idea of interactive lessons :)

[Edit]: You may notice i made showlesson(); a public function. I intend to link all these weapons together to form a much more interactive lesson scheme.

xXziroXx 10-06-2006 07:33 PM

I vote YES for you as president! ... I mean to this being a good idea :D

Draenin 10-06-2006 07:33 PM

I personally think this is a great idea.

Skyld 10-06-2006 07:43 PM

The idea is a very good one. It is maybe a good idea to store the documens in an IRC bot so that the user would not have to download each lesson (they can instead download only the ones they want).

The lessons should be a little more descriptive though. ;)

Twinny 10-06-2006 07:45 PM

Quote:

Originally Posted by Skyld (Post 1226721)
The lessons should be a little more descriptive though. ;)

Of course >_<. That lesson will be cleaned up before it becomes the first lesson. Just giving people an idea.

I'm not sure how I will end up managing the lessons. I was thinking of having a lesson manager with a dropdown of each lesson. The user could select the lesson they want. But yeah...i'll worry when i get to that stage =p

steve2 10-06-2006 08:21 PM

I like your idea Twinny :) really awesome

Crono 10-06-2006 08:29 PM

twinny for god of #gscript irc channel

smirt362 10-06-2006 08:47 PM

Great idea!
I'd definately use it.

Twinny 10-06-2006 08:52 PM

Only real bad thing is that these will need a server to be useful :cry: . If graal editor ever gets GS2 functionality then it will all be sweet.

xXziroXx 10-06-2006 08:55 PM

Quote:

Originally Posted by Twinny (Post 1226796)
Only real bad thing is that these will need a server to be useful :cry: . If graal editor ever gets GS2 functionality then it will all be sweet.

If selectfilefordownload() worked, you could have the script generate a text/html tutorial that gets downloaded into the players Graal folder.

Twinny 10-06-2006 08:57 PM

I was just thinking about making it a website. I've got my VIP hosting as well as my linux shell which for some reason has web hosting >_<
Websites would have limited interactivity as I could not be bothered to make tutorials in PHP / Flash =p

Twinny 10-07-2006 01:33 PM

Ok. I have made an example for the second lesson - a practical based lesson. 400 lines of code but not all mine (<3 Jamilla/Novo) and comments/styling help to fill up that number. This also forced me to use 2 posts :cry:. No ripping off my tripple post >_<

PHP Code:

/* Lesson 2 : Practical */
//#CLIENTSIDE
function onCreated()
  
addGUIControls();

function 
onWeaponFired()
  
showLesson();
  
public function 
showLesson()
{
  new 
GuiWindowCtrl("Lesson2Window")
  {
    
profile       "GuiBlueWindowProfile";
    
extent        "450 300";
    
position      "5 5";
    
text          "Lesson 2 : Practical Lesson. By Twinny";
    
destroyonhide true;
    
canmaximize   false;
    
canresize     false;
    
    new 
GuiTextCtrl("Lesson2Title")
    {
      
profile          "GuiBlueTextProfile";
      
position         "10 25";
      
profile.fontsize 40;
      
text "Practical Lesson on Objects";
    }
    
    new 
GuiScrollCtrl("Lesson2Scroll")
    {
      
profile    "GuiBlueScrollProfile";
      
position   "15 75";
      
extent     "420 140";
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
visible    true;
      
canmove    true;
    
      new 
GuiMLTextCtrl("Lesson2Body")
      {
        
profile  "GuiBlueMLTextProfile";
        
position "5 5";
        
extent   "390 110";
      }
    }
    new 
GuiButtonCtrl("Lesson2Prac1")
    {
      
profile  "GuiBlueButtonProfile";
      
position "15 220";
      
extent   "420 30";
      
text     "Practical Lesson 1";
    }
    new 
GuiButtonCtrl("Lesson2Prac2")
    {
      
profile  "GuiBlueButtonProfile";
      
position "15 255";
      
extent   "420 30";
      
text     "Practical Lesson 2";
    }
          
  }
  
GraalControl.addControl(Lesson2Window);
  
setLesson();
}

function 
setLesson()
{
  
Lesson2Body.setText(
  
"Below are two practical lessons. The first prac lesson is a
  basic lesson. It shows all the functions, objects and variables
  contained within an object of your choosing." 
NL "" NL
  
  
"The second lesson is a bit more advanced. The second lesson 
  shows the interconnected ness of objects within graal.
  Objects and arrays can be expanded. The functions and variables
  are present just to show you what is in each object you find." 
NL "" NL
  
  
"Next lesson will involve some questions based on objects as well 
  as some examples and tasks. It is hoped by then you will have a 
  basic understanding of objects. All credit for the practical lessons
  should go to Jamilla/Novo. I modified the first practical lesson
  a fair bit but the second one is generally the same as his
  original work. Ask the lesson provider if you wish to receive
  the practical lesson's code." 
NL "" NL
  
  
"As always if this lesson was confusing as hell - just mail me at
  [email protected]"
  
);
}

function 
Lesson2Prac1.onAction()
  
showPrac1();

function 
Lesson2Prac2.onAction()
{
  if (
this.on
    
turnoff();
  else
    
turnon();
}
  
/* And now for the practical lessons. Once more - credit
goes to Jamilla/Novo */

/* Practical Lesson 1 */
/* Modified quite a bit */
function showPrac1()
{
  new 
GuiWindowCtrl("L2P1")
  {
    
profile  "GuiBlueWindowProfile";
    
position "5 5";
    
extent   "450 300";
    
text     "Lesson 2 : Practical 1. By Twinny";
    
destroyonhide true;
    
canmaximize   false;
    
canresize     false;
  
    new 
GuiTextCtrl("L2Prac1Title")
    {
      
profile  "GuiBlueTextProfile";
      
profile.fontsize 22;
      
position "90 25";
      
text     "Select your object than parse";
    }
    
    new 
GuiPopUpMenuCtrl("L2Prac1PopUp")
    {
      
profile "GuiBluePopUpMenuProfile"// -_-
      
position "10 55";
      
extent   "280 25";
    }
    new 
GuiButtonCtrl("L2Prac1B1")
    {
      
profile  "GuiBlueButtonProfile";
      
position "300 55";
      
extent   "140 25";
      
text     "Parse";
    }
    new 
GuiScrollCtrl("L2Prac1Scroll")
    {
      
profile    "GuiBlueScrollProfile";
      
position   "15 90";
      
extent     "420 200";
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
visible    true;
      
canmove    true;
    
      new 
GuiMLTextCtrl("L2Prac1Dump")
      {
        
profile  "GuiBlueMLTextProfile";
        
position "5 5";
        
extent   "390 180";
      }
    }
  }
  
GraalControl.addControl(L2P1);
  
setObjects();
}

function 
setObjects()
{
  
temp.objs = {"Player","Level""Allplayers",
  
"Allplayers[1]""GuiControl","Weapon"};
  for (
tp temp.objs)
    
L2Prac1PopUp.addrow(1,tp);
}

function 
L2Prac1B1.onAction()
{
  
L2Prac1Dump.text "";
  if (
L2Prac1PopUp.text == "Player")
    
var_dump(player);
  else if (
L2Prac1PopUp.text == "Level")
    
var_dump(player.level);
  else if (
L2Prac1PopUp.text == "Allplayers")
    
var_dump(allplayers);
  else if (
L2Prac1PopUp.text == "Allplayers[1]")
    
var_dump(allplayers[1]);
  else if (
L2Prac1PopUp.text == "GuiControl")
    
var_dump(new GuiControl(Test));
  else if (
L2Prac1PopUp.text == "Weapon")
    
var_dump(player.weapon);  
}

function 
var_dumpobj )
{
  if ( 
obj.type() in {0,1,3} )
  {
    
L2Prac1Dump.addtextobj SPC "=" SPC ParseValuemakevar(obj) ) @";" NL "",);
    return 
true;
  }
  
L2Prac1Dump.addtext"new" SPC obj.objectType() @"(\""obj.name @"\"){" NL "",);
  
temp.functions obj.getFunctions();
  for ( 
temp.functemp.functions )
    
L2Prac1Dump.addtext("  function" SPC temp.func@"()" NL "",1);
  
temp.vars obj.getVarNames();
  for (
temp.varitemp.vars )
    
L2Prac1Dump.addtext"  "temp.vari SPC "=" SPC ParseValueobj.(@ temp.vari ) ) @";" NL "",1);
  
L2Prac1Dump.addtext"};" NL "",);
}

function 
ParseValueobj )
{
  switch ( 
obj.type() )
  {
    case 
"0":
      return 
obj;
    case 
"1":
      return 
"\""obj @"\"";
    case 
"2":
      return 
obj.objectType();
    case 
"3":
      
temp.arr "{";
      
temp.0;
      for ( 
temp.subobjobj )
      {
        
temp.arr @= ParseValuetemp.subobj );
        if ( 
temp.!= obj.size() - 1)
          
temp.arr @= ", ";
        
temp.++;
      }
      
temp.arr @= "}";
      return 
temp.arr;
    break;
  }


Second practical example found below.

Twinny 10-07-2006 01:35 PM

And now : the conclusion

PHP Code:

/* Practical Lesson 2 */

function turnon()
{
  
this.on true;
  
GUIContainer.addControlDebugger_Window );
  
Debugger_Window.show();
  
getNodes();
}

function 
onPlayerEnters()
{
  if ( !
this.on )
    return;
  
Debugger_Tree.clearnodes();
  
getNodes();
}

function 
turnoff()
{
  
this.on false;
  
Debugger_Tree.clearnodes();
  
Debugger_Window.hide();
}

function 
addGuiControls()
{
  new 
GuiWindowCtrl("Debugger_Window" )
  {
    
profile "GuiBlueWindowProfile";
    
position "440 0";
    
width 600;
    
height GUIContainer.height;
    
canMove canClose canMinimize true;
    
canResize canMaximize false;
    
text "Object Browser";
    
visible false;

    new 
GuiScrollCtrl("Debugger_Scroll") {
      
profile "GuiBlueScrollProfile";
      
horizSizing "width";
      
vertSizing "height";
      
position "5 23";
      
extent "590" SPC Debugger_Window.height 28;
      
willFirstRespond true;
      
hScrollBar "dynamic";
      
vScrollBar "alwaysOn";
      
tile true;

      new 
GuiTreeViewCtrl("Debugger_Tree") {
        
profile "GuiBlueTreeViewProfile";
        
0;
        
fitparentwidth true;
        
clearnodes();
      }
    }
  }
}

function 
getNodes()
{
  
CaddNodeDebugger_Treeallplayers"allplayers" );
  
CaddNodeDebugger_Treeplayers"players" );
  
CaddNodeDebugger_Treeplayer"player" );

  
CaddNodeDebugger_Treenpcs"npcs" );
  
CaddNodeDebugger_Treeplayer.weapons"weapons" );
  
CaddNodeDebugger_Treeplayer.level"level" );


  
CaddNodeDebugger_Treecompus"compus" );
  
CaddNodeDebugger_Treebombs"bombs" );
  
CaddNodeDebugger_Treearrows"arrows" );
  
CaddNodeDebugger_Treeitems"items" );
  
CaddNodeDebugger_Treehorses"horses" );
  
CaddNodeDebugger_Treesigns"signs" );

  
CaddNodeDebugger_TreeGUIContainer"GUIContainer" );
  
CaddNodeDebugger_TreeGraalControl"GraalControl" );
}

function 
Debugger_Tree.onSelectnode )
{
  
with node )
  {
    
clearnodes();
    switch ( 
this.nodereturn.type() )
    {
      case 
"0": case "1":
        
CaddNodenodenode.nodereturnnode.nodeparent @"."node.nodename );

        
temp.getObjKeysnode.nodeparent @"."node.nodename @"." );
        for ( 
temp.vtemp.)
          
CaddNodenodenode.nodereturn.(@ temp.), node.nodename @"."temp.);
      break;
      case 
"2":
        
temp.node.nodereturn.getFunctions();
        
CaddNodenodetemp.f"functions" );
        
temp.node.nodereturn.getVarNames();
        for ( 
temp.vtemp.)
          {
          if ( (
temp.v in temp.check) )
            continue;
          
temp.check.addtemp.);

          
temp.getObjKeysnode.nodereturntemp.@".");//.getVarNames();
          
for ( temp.ktemp.)
            
CaddNodenodemakevar("node.nodereturn."temp.@"."@temp.k) , temp.@"."temp.);
          
CaddNodenodemakevar("node.nodereturn."temp.v) , temp.);
          }
      break;
      case 
"3":
        for ( 
temp.0temp.node.nodereturn.size(); temp.++ )
          
CaddNodenodenode.nodereturntemp.], "["temp.@"]");
      break;
    }
  }
}

function 
CaddNodenodeobjvarname )
{
  
with node )
  {
    switch ( 
obj.type() )
    {
      case 
"0": case "1":
        
with addNodevarname SPC "=" SPC ParseValue(obj) @";" ) )
        {
          if ( 
node.returntype.type() == )
            
this.parentnode node.returntype;
          else 
this.parentnode node.parentnode;
          return 
this;
        }
      break;
      case 
"2":
        
with addNodevarname SPC "=" SPC ParseValueobj ) @";" ) )
        {
          if ( 
node.returntype.type() == )
            
this.parentnode node.returntype;
          else 
this.parentnode node.parentnode;
          
this.nodereturn obj;
          return 
this;
        }
      break;
      case 
"3":
        
with addNodevarname SPC "= new["obj.size() @"];" ) )
        {
          if ( 
node.returntype.type() == )
            
this.parentnode node.returntype;
          else 
this.parentnode node.parentnode;

          
this.nodereturn obj;

          return 
this;
        }
      break;
    }
  }
}
public function 
getObjKeysobjstrNeedle 

  if ( 
obj.type() != )
    return 
getstringkeysobj );

  
temp.vars obj.savevarstoarrayfalse ); 
  for ( 
temp.var: temp.vars 
    if ( 
temp.var.startsstrNeedle ) ) 
      
temp.keys.addtemp.var.substringstrNeedle.length(), temp.var.pos("=") - strNeedle.length()) );

  
this.toreturn temp.keys;
  return 
this.toreturn;


Both the scripts go in the same weapon. This weapon should be seperate from the weapon used to make Lesson 1.

[EDIT]: Fixed the problem. fitparentwidth = true; Good old Wiki =)

Zanzel 01-03-2007 05:51 PM

Very nice twinny, I found it quite usefull.

Crono 01-03-2007 06:11 PM

you never update the website by the way

scriptless 01-07-2011 02:34 PM

I know this is really old but how did the progress on this ever turn out? I am quite interested in this myself.. In-game gui's could be really helpful for teaching/refrencing..

Is there currently a way to check command's and there corresponding syntax online?? or do we have to rely on the forums and some command I can't remember ran thru the graal exe itself.. ?

Soala 01-07-2011 03:36 PM

Quote:

Originally Posted by scriptless (Post 1621057)
Is there currently a way to check command's and there corresponding syntax online?? or do we have to rely on the forums and some command I can't remember ran thru the graal exe itself.. ?

You can use /scripthelp on RC Chat to get help.

quick exemple: /scripthelp TStaticVar

Quote:

Script help for 'TStaticVar':
TStaticVar - object type, parent type is TGraalVar
TStaticVar.destroy()
TGraalVar.getstaticvarnames() - returns object - gets the names of all static (built-in) subvariables of this object

Twinny 01-07-2011 03:57 PM

Quote:

Originally Posted by scriptless (Post 1621057)
I know this is really old but how did the progress on this ever turn out? I am quite interested in this myself.. In-game gui's could be really helpful for teaching/refrencing..

Is there currently a way to check command's and there corresponding syntax online?? or do we have to rely on the forums and some command I can't remember ran thru the graal exe itself.. ?

This thing fell flat on it's butt after this one release but can't remember why

scriptless 01-07-2011 04:06 PM

Quote:

Originally Posted by Soala (Post 1621066)
You can use /scripthelp on RC Chat to get help.

quick exemple: /scripthelp TStaticVar

would be neat if scripted rc worked.. player list wont work for me either.. lol

Soala 01-07-2011 04:11 PM

Quote:

Originally Posted by scriptless (Post 1621070)
would be neat if scripted rc worked.. player list wont work for me either.. lol

I don't have the playerlist on scripted RC but you can still use /scripthelp


All times are GMT +2. The time now is 03:53 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.