Index: cpp/gdk/neuroimpl.cpp
===================================================================
--- cpp/gdk/neuroimpl.cpp	(revision 5)
+++ cpp/gdk/neuroimpl.cpp	(revision 64)
@@ -1,5 +1,5 @@
-// This file is a part of Framsticks GDK library.
-// Copyright (C) 2002-2006  Szymon Ulatowski.  See LICENSE.txt for details.
-// Refer to http://www.frams.alife.pl/ for further information.
+// This file is a part of the Framsticks GDK library.
+// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
 
 #include "neuroimpl.h"
@@ -23,5 +23,5 @@
 {
 {"Creature: Neurons",1,2,"nnsim",},
-{"randinit",1,0,"Random initialization","f 0 10 0.01",FIELD(randominit),"Initialize all neuron states with uniform distribution random numbers"},
+{"randinit",1,0,"Random initialization","f 0 10 0.01",FIELD(randominit),"Allowed range for initializing all neuron states with uniform distribution random numbers and zero mean. Set 0 for deterministic initialization."},
 {"touchrange",1,0,"T receptor range","f 0 100 1",FIELD(touchrange),},
 {0,0,0,},
@@ -277,40 +277,40 @@
 ParamEntry neuroimpl_tab[]=
 {
-{"Neuro",1,26+NEUROIMPL_SIGNAL_PROPS,"Neuro","Live Neuron object."},
-
-{"getInputState",0,0,"get input signal","p f(d input)",PROCEDURE(p_get),},
-{"getInputWeight",0,0,"get input weight","p f(d input)",PROCEDURE(p_getweight),},
-{"getWeightedInputState",0,0,"get weighted input signal","p f(d input)",PROCEDURE(p_getw),},
-{"getInputSum",0,0,"get signal sum","p f(d input)",PROCEDURE(p_getsum),},
-{"getWeightedInputSum",0,0,"get weighted signal sum","p f(d input)",PROCEDURE(p_getwsum),"uses any number of inputs starting with the specified input. getWeightedInputSum(0)=weightedInputSum"},
-{"getInputCount",0,0,"get input count","d",GETONLY(count),},
-{"inputSum",0,0,"full signal sum","f",GETONLY(sum),},
-{"weightedInputSum",0,0,"full weighted signal sum","f",GETONLY(wsum),},
-{"getInputChannelCount",0,0,"get channel count for input","p d(d input)",PROCEDURE(p_getchancount),},
-{"getInputStateChannel",0,0,"get input signal from channel","p f(d input,d channel)",PROCEDURE(p_getchan),},
-{"getWeightedInputStateChannel",0,0,"get weighted input signal from channel","p f(d input,d channel)",PROCEDURE(p_getwchan),},
-{"state",0,0,"neuron state (channel 0)","f",GETSET(state),"when read, returns the current neuron state.\nWhen written, sets the next neuron state (for use in the neuron definition)"},
-{"channelCount",0,0,"number of output channels","d",GETSET(channels),},
-{"getStateChannel",0,0,"get output state for channel","p f(d channel)",PROCEDURE(p_getstate),},
-{"setStateChannel",0,0,"set output state for channel","p(d channel,f value)",PROCEDURE(p_setstate),},
-{"hold",0,0,"Hold state","d 0 1",GETSET(hold),"",},
-{"currState",0,0,"neuron state (channel 0)","f",GETSET(cstate),"the only difference from the \"state\" field is that currState, when written, changes the internal neuron state immediately (which disturbs the regular synchronous NN operation). This feature should only be used while controlling the neuron 'from outside' (like a neuro probe) and not in the neuron definition.",},
-{"setCurrStateChannel",0,0,"set neuron for channel","p(d channel,f value)",PROCEDURE(p_setcstate),"like \"currState\""},
-{"position_x",0,0,"position x","f",GETONLY(position_x),},
-{"position_y",0,0,"position y","f",GETONLY(position_y),},
-{"position_z",0,0,"position z","f",GETONLY(position_z),},
-{"creature",0,0,"get owner creature","o Creature",GETONLY(creature),},
-{"part",0,0,"the Part object where this neuron is located","o MechPart",GETONLY(part),},
-{"joint",0,0,"the Joint object where this neuron is located","o MechJoint",GETONLY(joint),},
-{"fields",0,0,"custom neuron fields","o Fields",GETONLY(fields),
+{"Neuro",1,27+NEUROIMPL_SIGNAL_PROPS,"Neuro","Live Neuron object."},
+
+{"getInputState",0,0,"Get input signal","p f(d input)",PROCEDURE(p_get),},
+{"getInputWeight",0,0,"Get input weight","p f(d input)",PROCEDURE(p_getweight),},
+{"getWeightedInputState",0,0,"Get weighted input signal","p f(d input)",PROCEDURE(p_getw),},
+{"getInputSum",0,0,"Get signal sum","p f(d input)",PROCEDURE(p_getsum),},
+{"getWeightedInputSum",0,0,"Get weighted signal sum","p f(d input)",PROCEDURE(p_getwsum),"Uses any number of inputs starting with the specified input. getWeightedInputSum(0)=weightedInputSum"},
+{"getInputCount",0,0,"Get input count","d",GETONLY(count),},
+{"inputSum",0,0,"Full signal sum","f",GETONLY(sum),},
+{"weightedInputSum",0,0,"Full weighted signal sum","f",GETONLY(wsum),},
+{"getInputChannelCount",0,0,"Get channel count for input","p d(d input)",PROCEDURE(p_getchancount),},
+{"getInputStateChannel",0,0,"Get input signal from channel","p f(d input,d channel)",PROCEDURE(p_getchan),},
+{"getWeightedInputStateChannel",0,0,"Get weighted input signal from channel","p f(d input,d channel)",PROCEDURE(p_getwchan),},
+{"state",0,0,"Neuron state (channel 0)","f",GETSET(state),"When read, returns the current neuron state.\nWhen written, sets the next neuron state (for use in the neuron definition)"},
+{"channelCount",0,0,"Number of output channels","d",GETSET(channels),},
+{"getStateChannel",0,0,"Get output state for channel","p f(d channel)",PROCEDURE(p_getstate),},
+{"setStateChannel",0,0,"Set output state for channel","p(d channel,f value)",PROCEDURE(p_setstate),},
+{"hold",0,0,"Hold state","d 0 1",GETSET(hold),"\"Holding\" means keeping the neuron state as is, blocking the regular neuron operation. This is useful when your script needs to inject some control signals into the NN. Without \"holding\", live neurons would be constantly overwriting your changes, and the rest of the NN could see inconsistent states, depending on the connections. Setting hold=1 ensures the neuron state will be only set by you, and not by the neuron. The enforced signal value can be set using Neuro.currState before or after setting hold=1. Set hold=0 to resume normal operation.",},
+{"currState",0,0,"Neuron state (channel 0)","f",GETSET(cstate),"The only difference from the \"state\" field is that currState, when written, changes the internal neuron state immediately (which disturbs the regular synchronous NN operation). This feature should only be used while controlling the neuron 'from outside' (like a neuro probe) and not in the neuron definition. See also: Neuro.hold",},
+{"setCurrStateChannel",0,0,"Set neuron for channel","p(d channel,f value)",PROCEDURE(p_setcstate),"Analogous to \"currState\"."},
+{"position_x",0,0,"Position x","f",GETONLY(position_x),},
+{"position_y",0,0,"Position y","f",GETONLY(position_y),},
+{"position_z",0,0,"Position z","f",GETONLY(position_z),},
+{"creature",0,0,"Gets owner creature","o Creature",GETONLY(creature),},
+{"part",0,0,"The Part object where this neuron is located","o MechPart",GETONLY(part),},
+{"joint",0,0,"The Joint object where this neuron is located","o MechJoint",GETONLY(joint),},
+{"fields",0,0,"Custom neuron fields","o Fields",GETONLY(fields),
 "Neurons can have different fields depending on their class. Script neurons have their fields defined using the \"prop:\" syntax. If you develop a custom neuron script you should use the Fields object for accessing your own neuron fields. The Neuro.fields property is meant for accessing the neuron fields from the outside script.\n"
 "Examples:\n"
-"var c=LiveLibrary.createFromString(\"X[N]\");\n"
+"var c=Populations.createFromString(\"X[N]\");\n"
 "Simulator.print(\"standard neuron inertia=\"+c.getNeuro(0).fields.in);\n"
-"c=LiveLibrary.createFromString(\"X[Nn,e:0.1]\");\n"
+"c=Populations.createFromString(\"X[Nn,e:0.1]\");\n"
 "Simulator.print(\"noisy neuron error rate=\"+c.getNeuro(0).fields.e);\n"
 "\n"
 "The Interface object can be used to discover which fields are available for a certain neuron object:\n"
-"c=LiveLibrary.createFromString(\"X[N]\");\n"
+"c=Populations.createFromString(\"X[N]\");\n"
 "var iobj=Interface.makeFrom(c.getNeuro(0).fields);\n"
 "var i;\n"
@@ -318,4 +318,5 @@
 " Simulator.print(iobj.getId(i)+\" (\"+iobj.getName(i)+\")\");",},
 {"def",0,0,"Neuron definition from which this live neuron was built","o NeuroDef",GETONLY(neurodef),},
+{"classObject",0,0,"Neuron class for this neuron","o NeuroClass",GETONLY(classObject),},
 #ifdef NEURO_SIGNALS
 {"signals",0,PARAM_READONLY,"Signals","o NeuroSignals",FIELD(sigs_obj),},
@@ -332,15 +333,15 @@
 
 #define FIELDSTRUCT NeuroSignals
-{"add",0,PARAM_NOSTATIC,"add","p(s channel)",PROCEDURE(p_add),"Create a new signal"},
-{"receive",0,PARAM_NOSTATIC,"receive","p f(s channel)",PROCEDURE(p_receive),"Receive the aggregated signal power in a given channel."},
-{"receiveSet",0,PARAM_NOSTATIC,"receive","p oVector(s channel,f max distance)",PROCEDURE(p_receiveSet),"Get all signals in the specified range. Returns a readonly vector object containing Signal objects (individual signals can be accessed as result[0] throught result[result.size-1])."},
+{"add",0,PARAM_NOSTATIC,"Add","p(s channel)",PROCEDURE(p_add),"Create a new signal"},
+{"receive",0,PARAM_NOSTATIC,"Receive","p f(s channel)",PROCEDURE(p_receive),"Receive the aggregated signal power in a given channel."},
+{"receiveSet",0,PARAM_NOSTATIC,"Receive","p oVector(s channel,f max distance)",PROCEDURE(p_receiveSet),"Get all signals in the specified range. Returns a readonly vector object containing Signal objects (individual signals can be accessed as result[0] throught result[result.size-1])."},
 {"receiveFilter",0,PARAM_NOSTATIC,"receive","p f(s channel,f max distance,f flavor,f filter)",PROCEDURE(p_receiveFilter),"Receive the aggregated signal power in a given channel.\n\nAdditional filtering options:\n- Max distance only receives the neighbor signals (based on their physical location)\n- Flavor filtering: only signals having the flavor close to the specified one will be received. The filter value is the maximum allowed difference."},
-{"receiveSingle",0,PARAM_NOSTATIC,"receive","p oSignal(s channel,f range)",PROCEDURE(p_receiveSingle),"Find the signal source having the highest signal power (including the distance)"},
+{"receiveSingle",0,PARAM_NOSTATIC,"Receive","p oSignal(s channel,f range)",PROCEDURE(p_receiveSingle),"Find the signal source having the highest signal power (including the distance)"},
 #undef FIELDSTRUCT
 
 #define FIELDSTRUCT SignalSet
-{"get",0,PARAM_NOSTATIC,"get","p oSignal(d index)",PROCEDURE(p_get),},
-{"size",0,1+PARAM_NOSTATIC,"size","d",GETONLY(size),},
-{"clear",0,1+PARAM_NOSTATIC,"clear","p()",PROCEDURE(p_clear),},
+{"get",0,PARAM_NOSTATIC,"Get","p oSignal(d index)",PROCEDURE(p_get),},
+{"size",0,1+PARAM_NOSTATIC,"Size","d",GETONLY(size),},
+{"clear",0,1+PARAM_NOSTATIC,"Clear","p()",PROCEDURE(p_clear),},
 #undef FIELDSTRUCT
 {0,0,0,},
@@ -383,8 +384,12 @@
 void NeuroSignals::p_add(PARAMPROCARGS)
 {
-if (!owner->owner->channels) {ret->setEmpty();return;}
-SigChannel *ch=owner->owner->channels->getChannel(args->getString(),true);
 SigSource *s=new NeuroSigSource(owner,getCreature());
-ch->addSource(s);
+if (owner->owner->channels)
+	{
+	SigChannel *ch=owner->owner->channels->getChannel(args->getString(),true);
+	ch->addSource(s);
+	}
+else
+	SigChannel::dummy_channel.addSource(s);
 sigs+=s;
 s->setupObject(ret);
@@ -522,4 +527,9 @@
 }
 
+void NeuroImpl::get_classObject(ExtValue *ret)
+{
+NeuroClassExt::makeStaticObject(ret,neuroclass);
+}
+
 NeuroImpl::~NeuroImpl()
 {
