sets the scale factor of the game object instance * The scale factor is relative to the parent (if any). The global world scale factor cannot be manually set. * * [icon:attention] See manual to know how physics affected when setting scale from this function. * * @name go.set_scale * @param scale [type:n
| 1053 | * ``` |
| 1054 | */ |
| 1055 | static int Script_SetScale(lua_State* L) |
| 1056 | { |
| 1057 | Instance* instance = ResolveInstance(L, 2); |
| 1058 | |
| 1059 | // Supports both vector and number |
| 1060 | Vector3* v = dmScript::ToVector3(L, 1); |
| 1061 | if (v != 0) |
| 1062 | { |
| 1063 | Vector3 scale = *v; |
| 1064 | if (scale.getX() <= 0.0f || scale.getY() <= 0.0f || scale.getZ() <= 0.0f) |
| 1065 | { |
| 1066 | return luaL_error(L, "Vector passed to go.set_scale contains components that are below or equal to zero"); |
| 1067 | } |
| 1068 | dmGameObject::SetScale(instance, scale); |
| 1069 | return 0; |
| 1070 | } |
| 1071 | |
| 1072 | lua_Number n = luaL_checknumber(L, 1); |
| 1073 | if (n <= 0.0) |
| 1074 | { |
| 1075 | return luaL_error(L, "The scale supplied to go.set_scale must be greater than 0."); |
| 1076 | } |
| 1077 | dmGameObject::SetScale(instance, (float)n); |
| 1078 | return 0; |
| 1079 | } |
| 1080 | |
| 1081 | /*# sets the scale factor only for width and height (x and y) of the game object instance |
| 1082 | * The scale factor is relative to the parent (if any). The global world scale factor cannot be manually set. |
nothing calls this directly
no test coverage detected