Can now pass tokens as values in animation steps
This commit is contained in:
@@ -52,12 +52,7 @@
|
||||
// for all key-value pairs do:
|
||||
// write_string(key)
|
||||
// write_bool(persistent)
|
||||
// write_uint8(type) // T_STRING, T_NUMBER, T_BOOL, or T_XYZ
|
||||
// switch type:
|
||||
// T_STRING: write_string(value)
|
||||
// T_NUMBER: write_double(value)
|
||||
// T_BOOL: write_bool(value)
|
||||
// T_XYZ: write_xyz(value)
|
||||
// write_simple_dynamic(value)
|
||||
//
|
||||
// The encoded string produced by the loop above is called an "encstep".
|
||||
// That's short for "encoded animation step". The encstep has a hash
|
||||
@@ -107,10 +102,19 @@ struct AnimValue : public SimpleDynamicValue {
|
||||
|
||||
AnimValue() { persistent = false; }
|
||||
|
||||
void set_token(LuaToken token) {
|
||||
type = SimpleDynamicTag::TOKEN;
|
||||
s=token.str(); x=y=z=0;
|
||||
}
|
||||
|
||||
void set_dxyz(const util::DXYZ &xyz) {
|
||||
type = SimpleDynamicTag::VECTOR;
|
||||
s.clear(); x = xyz.x; y = xyz.y; z = xyz.z;
|
||||
}
|
||||
|
||||
bool is_token(const char *t) const {
|
||||
return (type == SimpleDynamicTag::TOKEN) && (s == t);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -141,10 +145,11 @@ public:
|
||||
// Set a single variable to a value of a specified type.
|
||||
// If the variable isn't present, add it.
|
||||
//
|
||||
void set_boolean(const eng::string &name, bool v);
|
||||
void set_number(const eng::string &name, double v);
|
||||
void set_dxyz(const eng::string &name, const util::DXYZ &value);
|
||||
void set_string(const eng::string &name, std::string_view value);
|
||||
void set_string(const eng::string &name, std::string_view v) { map_[name].set_string(v); }
|
||||
void set_token(const eng::string &name, LuaToken v) { map_[name].set_token(v); }
|
||||
void set_number(const eng::string &name, double v) { map_[name].set_number(v); }
|
||||
void set_boolean(const eng::string &name, bool v) { map_[name].set_boolean(v); }
|
||||
void set_dxyz(const eng::string &name, const util::DXYZ &v) { map_[name].set_dxyz(v); }
|
||||
|
||||
// Print a debug string into the stringstream.
|
||||
//
|
||||
@@ -217,10 +222,10 @@ public:
|
||||
|
||||
// Convert an animstate to a lua table.
|
||||
//
|
||||
// You can either convert the persistent key-value pairs, or the
|
||||
// nonpersistent. So you'll need two lua tables to store both.
|
||||
// You can specify whether you want to include the transient values, the
|
||||
// persistent values, or both.
|
||||
//
|
||||
void to_lua(LuaCoreStack &LS, LuaSlot tab, bool persistent);
|
||||
void to_lua(LuaCoreStack &LS, LuaSlot tab, bool transient, bool persistent);
|
||||
|
||||
// Parse a string, for unit testing.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user