1
This commit is contained in:
parent
f1902a4289
commit
e161c89e03
@ -16,12 +16,12 @@ public:
|
||||
"getSkillNumber",
|
||||
[this] (const a8::lisp::List& params) -> std::shared_ptr<a8::lisp::Value>
|
||||
{
|
||||
a8::lisp::Atom result;
|
||||
double result = 0;
|
||||
if (params->size() != 1) {
|
||||
abort();
|
||||
}
|
||||
result.val = context_.skill_meta->_number_meta->_float_speed;
|
||||
return std::make_shared<a8::lisp::Value>(result);
|
||||
result = context_.skill_meta->_number_meta->_float_speed;
|
||||
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||
});
|
||||
}
|
||||
|
||||
@ -32,8 +32,19 @@ public:
|
||||
context_.c = c;
|
||||
context_.skill_meta = skill_meta;
|
||||
|
||||
auto result = a8::lisp::Expr::Eval(expr, shared_from_this());
|
||||
|
||||
context_.c = nullptr;
|
||||
context_.skill_meta = nullptr;
|
||||
|
||||
if (!result) {
|
||||
abort();
|
||||
}
|
||||
if (!result->IsType(a8::lisp::ValueType::kAtom)) {
|
||||
abort();
|
||||
}
|
||||
auto&& atom = std::any_cast<a8::lisp::Atom>(result->value);
|
||||
return atom.val;
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::lisp::Value> Compile(const std::string& script)
|
||||
@ -58,6 +69,18 @@ public:
|
||||
abort();
|
||||
}
|
||||
auto func_call_exprs = std::make_shared<a8::lisp::List::element_type>();
|
||||
{
|
||||
auto cproc = Find("getSkillNumber");
|
||||
if (!cproc) {
|
||||
abort();
|
||||
}
|
||||
if (!cproc->IsType(a8::lisp::ValueType::kCProc)) {
|
||||
abort();
|
||||
}
|
||||
func_call_exprs->push_back(cproc);
|
||||
func_call_exprs->push_back
|
||||
(std::make_shared<a8::lisp::Value>(a8::lisp::Atom(idx)));
|
||||
}
|
||||
node->Assign(func_call_exprs);
|
||||
|
||||
} else if (node->IsType(a8::lisp::ValueType::kList)) {
|
||||
@ -79,7 +102,8 @@ private:
|
||||
|
||||
void LispEnv::Init()
|
||||
{
|
||||
|
||||
skill_env_ = std::make_shared<SkillScope>();
|
||||
skill_env_->Init();
|
||||
}
|
||||
|
||||
void LispEnv::UnInit()
|
||||
|
@ -112,7 +112,10 @@ namespace mt
|
||||
|
||||
int SkillNumber::GetAttrIdxByName(const std::string& name)
|
||||
{
|
||||
|
||||
if (name == "${skillNumber.speed}") {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
2
third_party/a8
vendored
2
third_party/a8
vendored
@ -1 +1 @@
|
||||
Subproject commit b075c000c2c52a674bb7c27a398dc3a795b40d8f
|
||||
Subproject commit 24625f05d1636709680b03de74b60d2b4736d7d5
|
Loading…
x
Reference in New Issue
Block a user