Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

View Poll Results: Is this a good idea?
Yes 33 100.00%
No 0 0%
Voters: 33. You may not vote on this poll

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-06-2006, 07:31 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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.
Reply With Quote
  #2  
Old 10-06-2006, 07:33 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I vote YES for you as president! ... I mean to this being a good idea
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #3  
Old 10-06-2006, 07:33 PM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
I personally think this is a great idea.
Reply With Quote
  #4  
Old 10-06-2006, 07:43 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
Reply With Quote
  #5  
Old 10-06-2006, 07:45 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Skyld View Post
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
Reply With Quote
  #6  
Old 10-06-2006, 08:21 PM
steve2 steve2 is offline
Steve (Scripter)
Join Date: Jul 2005
Location: Canada
Posts: 32
steve2 is on a distinguished road
Send a message via AIM to steve2 Send a message via MSN to steve2
I like your idea Twinny really awesome
Reply With Quote
  #7  
Old 10-06-2006, 08:29 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
twinny for god of #gscript irc channel
__________________
Reply With Quote
  #8  
Old 10-06-2006, 08:47 PM
smirt362 smirt362 is offline
Tee Hee
smirt362's Avatar
Join Date: Feb 2005
Location: Texas
Posts: 2,101
smirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant future
Send a message via AIM to smirt362 Send a message via MSN to smirt362
Great idea!
I'd definately use it.
__________________

Don Hertzfeldt <3
Reply With Quote
  #9  
Old 10-06-2006, 08:52 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Only real bad thing is that these will need a server to be useful . If graal editor ever gets GS2 functionality then it will all be sweet.
Reply With Quote
  #10  
Old 10-06-2006, 08:55 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Twinny View Post
Only real bad thing is that these will need a server to be useful . 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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 10-06-2006, 08:57 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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
Reply With Quote
  #12  
Old 10-07-2006, 01:33 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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 . 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.
Reply With Quote
  #13  
Old 10-07-2006, 01:35 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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 =)

Last edited by Twinny; 07-14-2007 at 11:26 AM..
Reply With Quote
  #14  
Old 01-03-2007, 05:51 PM
Zanzel Zanzel is offline
<insert title here>
Zanzel's Avatar
Join Date: Dec 2006
Posts: 35
Zanzel is on a distinguished road
Very nice twinny, I found it quite usefull.
Reply With Quote
  #15  
Old 01-03-2007, 06:11 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
you never update the website by the way
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:16 PM.


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