* animation file.
*/
- Frame(Mf::Script& script, Mf::Script::Slot table) :
+ Frame(const Mf::Script::Slot& table) :
mIndex(0),
mDuration(1.0)
{
- table.pushField("index");
- script[-1].get(mIndex);
- script.pop();
-
- table.pushField("duration");
- script[-1].get(mDuration);
- script.pop();
+ table.get(mIndex, "index");
+ table.get(mDuration, "duration");
}
};
* the frame's constructor which loads each individual frame.
*/
- Sequence(Mf::Script& script, Mf::Script::Slot table) :
+ Sequence(const Mf::Script::Slot& table) :
mDelay(0.0),
mLoop(true)
{
- table.pushField("delay");
- script[-1].get(mDelay);
- script.pop();
-
- table.pushField("loop");
- script[-1].get(mLoop);
- script.pop();
-
- table.pushField("next");
- script[-1].get(mNext);
- script.pop();
+ table.get(mDelay, "delay");
+ table.get(mLoop, "loop");
+ table.get(mNext, "next");
// TODO - sequence class/type not yet implemented
- table.pushField("frames");
- Mf::Script::Slot frameTable = script.getTop();
+ Mf::Script::Slot frameTable = table.pushField("frames");
if (frameTable.isTable())
{
- Mf::Script::Slot top = script[-1];
- int index = 1;
-
- for (;;)
+ int max = frameTable.length();
+ for (int index = 1; index <= max; ++index)
{
- script.push(index);
- frameTable.pushField();
+ Mf::Script::Slot top = frameTable.pushField(index);
if (top.isTable())
{
- mFrames.push_back(Frame(script, top));
+ mFrames.push_back(Frame(top));
+ }
+ else
+ {
+ Mf::logWarning << "invalid frame at index "
+ << index << std::endl;
}
- else break;
-
- ++index;
}
}
- script.pop();
+ frameTable.remove();
}
};
std::string nameStr;
name.get(nameStr);
- mSequences.insert(std::make_pair(nameStr,
- Sequence(script, table)));
+ mSequences.insert(std::make_pair(nameStr, Sequence(table)));
return 0;
}
boost::bind(&Data::defineSequence,
this, _1));
- script.push(1); script.set("ATTACK");
- script.push(2); script.set("CHARGE");
- script.push(3); script.set("FLY");
- script.push(4); script.set("HIT");
- script.push(5); script.set("JUMP");
- script.push(6); script.set("RUN");
- script.push(7); script.set("STAND");
+ script.globals().setField("ATTACK", 1);
+ script.globals().setField("CHARGE", 2);
+ script.globals().setField("FLY", 3);
+ script.globals().setField("HIT", 4);
+ script.globals().setField("JUMP", 5);
+ script.globals().setField("RUN", 6);
+ script.globals().setField("STAND", 7);
}