Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/06/2019 in Posts

  1. Start by reading the description. It also says that you must first remove the original from the market.
    1 point
  2. A review of the example above for anyone who wonders why it works and why one should not code like this. Second line contains the following code: DESTROYER = gg.makeRequest("link").content There are 3 main steps in this code: 1. "makeRequest" function from "gg" table is called with the corresponding argument. 2. Result returned by the function is indexed with the key "content". 3. Value from the step 2 is saved in "DESTROYER" variable. Then, on the third line there is the following code: if not DESTROYER then which checks the condition and executes the code after "then" keyword, if the condition is true. Otherwise, it executes the code after "else" keyword. To understand, why "one should not code like this", let's review the documentation for "makeRequest" function at GG help. https://gameguardian.net/help/classgg.html#ad020d50d3af0a36733e0cbc231055c55 In this case we are interested in the description of the value returned by the function: Now, let's get back to the second line of the example. When function succeeds, the code from the second line behaves as intended. Table returned by the function is indexed with the key "content" and the result of this operation is stored in the variable. And what happens, when there is an error? String returned by the function is indexed with the key "content" and the value is stored in the variable. By default, there is no meaning of indexing string with a key and luckily for the example, the value returned by such operation is nil. But this behavior is not obvious and not obvious behavior may often lead to errors. Then how can the example be modified to avoid non-obvious behavior? The result of the call to "makeRequest" function should be saved to a variable. Then the type of the variable should be checked. If it is "table", the function has succeeded, the variable can be indexed with the key "content" and the result of this operation can be stored in another variable. And if it is "string", then an error occurred, the contents of the variable can be printed to log (via "print" function) and/or shown to the user (via "alert" function). Example to illustrate the answer above: local functionResult = gg.makeRequest('link') local content if type(functionResult) == 'table' then content = functionResult.content elseif type(functionResult) == 'string' then -- print/alert error description end -- other actions Such modification to the code explicitly shows which actions will be performed and when (function succeeds / function fails) getting rid from non-obvious behavior.
    1 point
  3. Once again, there is a contradiction between your statement and the reality: You keep repeating that there is "execution error" in @TopGEOYT's script "when cancelling" and that your's example does not have it, but without the correction of what you have called "syntax" your example is meaningless and TopGEOYT's is not. We don't know, have you known about the mistake in your example or not before I have corrected it. Therefore, simple conclusion can be made: your example is worse than TopGEOYT's.
    1 point
  4. View File Error handling for GG API functions template Note: This file is intended to be used by script developers. If you don't develop scripts or don't know what it is, ignore this file. Description: The file consists of three functions: - "attachHandler" function modifies a function in a way that when it returns a string, specified error handling function is called with that string as argument. It returns modified version of the function. This function should only be used on functions that return a string with error description when an error occurs. There is a list of such functions from GG API in the file. - "defaultHandler" function is an example of error handling function. - "testError" function (commented by default) "simulates" a function that has returned a string with error description, used for testing. How to use: 1. Include contents of the file at the beginning of your code. 2. Optionally create custom error handling functions. Error handling function has to accept 1 argument - a string with error description. 3. Use "attachHandler" function to get modified version of the function and either redefine original function with it or store it in a new variable. 4. Repeat step 3 for all desired functions. Examples: -- Custom error handling function local function myHandler(errorText) gg.toast('Whoops, looks like something went wrong', true) gg.toast('Mysterious error: ' .. errorText) print('Description of the error that has occurred during script execution:\n' .. errorText) end -- Using default error handling function and redefining the original function gg.searchNumber = attachHandler(gg.searchNumber, defaultHandler) -- Using custom error handling function and storing modified function in a new variable local getResultsModified = attachHandler(gg.getResults, myHandler) -- If an error occurs, "defaultHandler" function will be called gg.searchNumber('123', gg.TYPE_DWORD) -- If an error occurs, no error handling function will be called local results1 = gg.getResults(100) -- If an error occurs, "myHandler" function will be called local results2 = getResultsModified(100) Submitter CmP Submitted 01/01/2019 Category Templates  
    1 point
  5. View File Monitor saved values This script is intended for tracking changes of the values in the saved list. It will output details (time, name of saved list element, it's address, old value, new value) of recorded changes in a convenient form when user decides to finish monitoring. Submitter CmP Submitted 05/01/18 Category LUA scripts
    1 point
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.