NS2 修改节点颜色问题记录
$ns_ at 0.1 "$node_(14) color \"red\""
0.1s使14节点变成红色,报错:
Warning: Node::change-color is obsolete. Use Node::color instead
ns: _o322 change-color "red": can't read "attr_(COLOR)": no such variable
while executing
"eval list "n -t [format "%.15g" [$ns now]] -s $id_ -S COLOR -c $color -o $attr_(COLOR) -i $color -I $attr_(LCOLOR)""
invoked from within
"if [$ns is-started] {
$ns puts-nam-config [eval list "n -t [format "%.15g" [$ns now]] -s $id_ -S COLOR -c $color -o $attr_(COLOR) -i $color -I $attr..."
(procedure "_o322" line 6)
(Node color line 6)
invoked from within
"$self color $color"
(procedure "_o322" line 3)
(Node change-color line 3)
invoked from within
"_o322 change-color "red""
修改./tcl/lib/ns-namsupp.tcl
Node instproc color { color } {
$self instvar attr_ id_
set ns [Simulator instance]
if [$ns is-started] {
# color must be initialized
set attr_(COLOR) $color
set attr_(LCOLOR) $color
$ns puts-nam-config \
[eval list "n -t [format "%.15g" [$ns now]] -s $id_ -S COLOR -c $color -o $attr_(COLOR) -i $color -I $attr_(LCOLOR)"]
} else {
set attr_(COLOR) $color
set attr_(LCOLOR) $color
}
}
重新make。