Jump to content

Cleaning up my TS functions database


Mud-H

Recommended Posts

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:

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...