int jass_set(lua_State* L) { lua::jassbind* lj = (lua::jassbind*)L; if (!is_gaming()) { return 0; } const char* name = lj->tostring(2); hashtable::variable_node* ptr = get_variable_hashtable()->get(name); if (ptr) { switch (ptr->type_) { case jass::OPCODE_VARIABLE_NOTHING: case jass::OPCODE_VARIABLE_UNKNOWN: case jass::OPCODE_VARIABLE_NULL: break; case jass::OPCODE_VARIABLE_CODE: // // Fixed me // break; case jass::OPCODE_VARIABLE_INTEGER: ptr->value_ = lj->read_integer(3); break; case jass::OPCODE_VARIABLE_REAL: ptr->value_ = lj->read_real(3); break; case jass::OPCODE_VARIABLE_STRING: // // Fixed me // break; case jass::OPCODE_VARIABLE_HANDLE: ptr->value_ = lj->read_handle(3); break; case jass::OPCODE_VARIABLE_BOOLEAN: ptr->value_ = lj->read_boolean(3); break; break; case jass::OPCODE_VARIABLE_INTEGER_ARRAY: case jass::OPCODE_VARIABLE_REAL_ARRAY: case jass::OPCODE_VARIABLE_STRING_ARRAY: case jass::OPCODE_VARIABLE_HANDLE_ARRAY: case jass::OPCODE_VARIABLE_BOOLEAN_ARRAY: break; default: break; } } return 0; }
global_variable::global_variable(const char* name) : ptr_(get_variable_hashtable()->get(name)) { }
int jass_get(lua_State* L) { lua::jassbind* lj = (lua::jassbind*)L; const char* name = lj->tostring(2); native_function::native_function const* nf = native_function::jass_func(name); if (nf) { lj->pushunsigned((uint32_t)(uintptr_t)nf); lj->pushcclosure((lua::state::cfunction)jass_call_closure, 1); return 1; } if (!is_gaming()) { lj->pushnil(); return 1; } hashtable::variable_node* node_ptr = get_variable_hashtable()->get(name); if (node_ptr) { switch (node_ptr->type_) { case jass::OPCODE_VARIABLE_NOTHING: case jass::OPCODE_VARIABLE_UNKNOWN: case jass::OPCODE_VARIABLE_NULL: lj->pushnil(); return 1; case jass::OPCODE_VARIABLE_CODE: lj->push_code(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_INTEGER: lj->push_integer(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_REAL: lj->push_real(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_STRING: lj->push_string(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_HANDLE: lj->push_handle(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_BOOLEAN: lj->push_boolean(node_ptr->value_); return 1; case jass::OPCODE_VARIABLE_INTEGER_ARRAY: case jass::OPCODE_VARIABLE_REAL_ARRAY: case jass::OPCODE_VARIABLE_STRING_ARRAY: case jass::OPCODE_VARIABLE_HANDLE_ARRAY: case jass::OPCODE_VARIABLE_BOOLEAN_ARRAY: // // Fixed me // lj->pushnil(); return 1; default: return 1; } } lj->pushnil(); return 1; }