set g_sandbox_info 1 "print non-critical information to the server"
set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in front of the player"
set g_sandbox_editor_distance_edit 350 "distance at which players can edit or remove objects they are looking at"
+set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to"
+set g_sandbox_object_scale_max 2 "maximum scale that objects can be set to"
seta menu_sandbox_spawn_model "" // used to store the model in the input field
set menu_sandbox_edit_skin 0
.string object_clipboard;
-entity sandbox_EditObject()
+entity sandbox_EditObject_Get()
{
// returns the traced entity if the player can edit it, and world if not
return world;
}
+void sandbox_EditObject_Scale(entity e, float f)
+{
+ e.scale = f;
+ if(e.scale)
+ {
+ e.scale = bound(autocvar_g_sandbox_object_scale_min, e.scale, autocvar_g_sandbox_object_scale_max);
+ setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+ }
+}
+
entity sandbox_SpawnObject()
{
// spawn a new object with default properties
// ---------------- COMMAND: REMOVE OBJECT ----------------
case "remove_object":
- e = sandbox_EditObject();
+ e = sandbox_EditObject_Get();
if(e != world)
{
if(autocvar_g_sandbox_info)
case "duplicate_object_copy":
// copies customizable properties of the selected object to the clipboard
- e = sandbox_EditObject(); // you can only copy objects you can edit, so this works
+ e = sandbox_EditObject_Get(); // you can only copy objects you can edit, so this works
if(e != world)
{
if(self.object_clipboard)
e.colormod = stov(argv(3));
e.glowmod = stov(argv(4));
e.frame = stof(argv(5));
- e.scale = stof(argv(6)); if(self.scale) setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+ sandbox_EditObject_Scale(e, stof(argv(6)));
e.movetype = stof(argv(7));
e.damageforcescale = stof(argv(8));
return TRUE;
}
- e = sandbox_EditObject();
+ e = sandbox_EditObject_Get();
if(e != world)
{
switch(argv(2))
e.frame = stof(argv(3));
break;
case "scale":
- e.scale = stof(argv(3));
- if(self.scale)
- setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+ sandbox_EditObject_Scale(e, stof(argv(3)));
break;
case "physics":
switch(argv(3))
entity e;
float grab;
- e = sandbox_EditObject();
+ e = sandbox_EditObject_Get();
if(e != world && vlen(e.origin - self.origin) <= autocvar_g_sandbox_editor_distance_edit)
grab = TRUE;