### Cleaning up my TS functions database

Scripting questions, discussions, etc

#### Cleaning up my TS functions database

Mud-H
Posts: 183
Joined: Thu Feb 19, 2015 3:08 pm
A while back, I have decided to regroup some general functions together in a helpers folders, now I decided it's time to make a cleanup in that folder and make it organized. Once completed, I will share it with the community in case some would be interested by some of the functions. Some are coming straight from Torque3D but most are new and allow to replace repetitive scripting with a single function.
Anyway, this is not the goal of this thread, I will post here some functions that I don't understand the need for. Maybe some of those are from old Torque3D versions (TGE and TGEA) and could be modified or removed.

For example, I came across the setSafeValue function which is used in the AggregateControl class, I like that class once I figured out what it was but I'm not sure if the safe value system is still needed. Here's the function:

Code: Select all

function GuiControl::setValueSafe(%this, %val) { %cmd = %this.command; %alt = %this.altCommand; %this.command = ""; %this.altCommand = ""; %this.setValue(%val); %this.command = %cmd; %this.altCommand = %alt; } 
Is there a reason to do that with the command/altCommand? I have never experienced a problem where such safety would be needed, anyone have an idea why this function is used in AggregateControl. Someone think it's still needed?

#### Re: Cleaning up my TS functions database

buckmaster
Steering Committee
Posts: 321
Joined: Thu Feb 05, 2015 1:02 am
I love that this is called setSafeValue. Belies the sort of selfish culture we programmers have where 'safe' means 'not running code that I didn't explicitly say to run'. This function removes event handlers from the GUI control so that they can't fire when we change the control's value using setValue. This is essentially a 'stealth update' so that if someone else was listening for value changes and meant to do something with them, then they can't.

#### Who is online

Users browsing this forum: No registered users and 2 guests