PDA

View Full Version : Interactive Lessons


Twinny
10-06-2006, 08:31 PM
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

/* 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

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, 08:33 PM
I vote YES for you as president! ... I mean to this being a good idea :D

Draenin
10-06-2006, 08:33 PM
I personally think this is a great idea.

Skyld
10-06-2006, 08: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, 08:45 PM
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, 09:21 PM
I like your idea Twinny :) really awesome

Crono
10-06-2006, 09:29 PM
twinny for god of #gscript irc channel

smirt362
10-06-2006, 09:47 PM
Great idea!
I'd definately use it.

Twinny
10-06-2006, 09: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, 09:55 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.

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, 09: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, 02: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 >_<


/* 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_dump( obj )
{
if ( obj.type() in {0,1,3} )
{
L2Prac1Dump.addtext( obj SPC "=" SPC ParseValue( makevar(obj) ) @";" NL "",1 );
return true;
}
L2Prac1Dump.addtext( "new" SPC obj.objectType() @"(\""@ obj.name @"\"){" NL "",1 );
temp.functions = obj.getFunctions();
for ( temp.func: temp.functions )
L2Prac1Dump.addtext(" function" SPC [email protected]"()" NL "",1);
temp.vars = obj.getVarNames();
for (temp.vari: temp.vars )
L2Prac1Dump.addtext( " "@ temp.vari SPC "=" SPC ParseValue( obj.(@ temp.vari ) ) @";" NL "",1);
L2Prac1Dump.addtext( "};" NL "",1 );
}

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


Second practical example found below.

Twinny
10-07-2006, 02:35 PM
And now : the conclusion


/* Practical Lesson 2 */

function turnon()
{
this.on = true;
GUIContainer.addControl( Debugger_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";
x = y = 0;
fitparentwidth = true;
clearnodes();
}
}
}
}

function getNodes()
{
CaddNode( Debugger_Tree, allplayers, "allplayers" );
CaddNode( Debugger_Tree, players, "players" );
CaddNode( Debugger_Tree, player, "player" );

CaddNode( Debugger_Tree, npcs, "npcs" );
CaddNode( Debugger_Tree, player.weapons, "weapons" );
CaddNode( Debugger_Tree, player.level, "level" );


CaddNode( Debugger_Tree, compus, "compus" );
CaddNode( Debugger_Tree, bombs, "bombs" );
CaddNode( Debugger_Tree, arrows, "arrows" );
CaddNode( Debugger_Tree, items, "items" );
CaddNode( Debugger_Tree, horses, "horses" );
CaddNode( Debugger_Tree, signs, "signs" );

CaddNode( Debugger_Tree, GUIContainer, "GUIContainer" );
CaddNode( Debugger_Tree, GraalControl, "GraalControl" );
}

function Debugger_Tree.onSelect( node )
{
with ( node )
{
clearnodes();
switch ( this.nodereturn.type() )
{
case "0": case "1":
CaddNode( node, node.nodereturn, node.nodeparent @"."@ node.nodename );

temp.i = getObjKeys( node.nodeparent @"."@ node.nodename @"." );
for ( temp.v: temp.i )
CaddNode( node, node.nodereturn.(@ temp.v ), node.nodename @"."@ temp.v );
break;
case "2":
temp.f = node.nodereturn.getFunctions();
CaddNode( node, temp.f, "functions" );
temp.i = node.nodereturn.getVarNames();
for ( temp.v: temp.i )
{
if ( (temp.v in temp.check) )
continue;
temp.check.add( temp.v );

temp.j = getObjKeys( node.nodereturn, temp.v @".");//.getVarNames();
for ( temp.k: temp.j )
CaddNode( node, makevar("node.nodereturn."@ temp.v @"."@temp.k) , temp.v @"."@ temp.k );
CaddNode( node, makevar("node.nodereturn."@ temp.v) , temp.v );
}
break;
case "3":
for ( temp.i = 0; temp.i < node.nodereturn.size(); temp.i ++ )
CaddNode( node, node.nodereturn[ temp.i ], "["@ temp.i @"]");
break;
}
}
}

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

this.nodereturn = obj;

return this;
}
break;
}
}
}
public function getObjKeys( obj, strNeedle )
{
if ( obj.type() != 2 )
return getstringkeys( obj );

temp.vars = obj.savevarstoarray( false );
for ( temp.var: temp.vars )
if ( temp.var.starts( strNeedle ) )
temp.keys.add( temp.var.substring( strNeedle.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
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

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
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
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
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