Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Make Instance.new only work for instances that exist
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Sep 24, 2019
1 parent 41f299d commit a2f6b2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Remodel Changelog

## Unreleased Changes
* **Breaking:** `Instance.new` now only works for instances that actually exist.
* Added `Instance:Clone()` for copying instances all over the place, as is Roblox tradition. ([#12](https://github.com/rojo-rbx/remodel/issues/12))
* Added `DataModel:GetService()` for finding services and creating them if they don't exist, like Roblox does.
* Improved error messages in preparation for [#7](https://github.com/rojo-rbx/remodel/issues/7) to be fixed upstream.
Expand Down
7 changes: 7 additions & 0 deletions src/roblox_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ struct Instance;
impl UserData for Instance {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_function("new", |context, class_name: String| {
if rbx_reflection::get_class_descriptor(&class_name).is_none() {
return Err(rlua::Error::external(format!(
"'{}' is not a valid class of Instance.",
class_name,
)));
}

let master_tree = RemodelContext::get(context)?.master_tree;
let mut master_handle = master_tree.lock().unwrap();

Expand Down

0 comments on commit a2f6b2f

Please sign in to comment.