Signup Now
Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1
    Free User Eldar's Avatar
    Join Date
    Dec 2013
    Posts
    2,385
    Reputation
    63
    Rep Power
    25

    getuseroption() - sometimes return nil

    Hello, I have problems with getuseroption(). Sometimes it return nil, after refresh action it return right value, but when it happen, return bugs like this:
    Code:
    error in Persistent script Variables:
      ["setsetting("Looting/LootList/".. ITEM .."..."]:Variables:106 attempt to compare number with nil
    And it stop whole action. To make it work I need to open action and click "OK".
    @Lucas Terra

  2. #2
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,441
    Reputation
    309
    Rep Power
    28
    Can we have the whole action?

  3. #3
    Free User Eldar's Avatar
    Join Date
    Dec 2013
    Posts
    2,385
    Reputation
    63
    Rep Power
    25
    Quote Originally Posted by Raphael View Post
    Can we have the whole action?
    -- getuseroption("HeavyItems") == "Halberd, Battle Shield, Plate Armor"
    HEAVY_ITEMS = {}

    auto(500)
    local ITEMS_SETUP = getuseroption("HeavyItems")

    if (ITEMS_SETUP ~= nil) then
    for HEAVY_ITEM in string.gmatch(ITEMS_SETUP, "([^,]+)") do -- line 98
    HEAVY_ITEM = string.gsub(HEAVY_ITEM, "^%s*(.-)%s*$", "%1")
    table.insert(HEAVY_ITEMS, string.lower(HEAVY_ITEM))
    end
    end

    for _, ITEM in ipairs(HEAVY_ITEMS) do
    if (getuseroption("CollectHeavyLoot")) then
    setsetting("Looting/LootList/".. ITEM .."/Action", $cap <= getuseroption("CapToDropHeavyLoot") and "Drop" or "Loot") -- line 106
    else
    setsetting("Looting/LootList/".. ITEM .."/Action", "Ignore")
    end
    end


    Action working good, because it sometimes return nil and after refresh action, it return correct value. Earlier it returned debug on line 98 (argument to string.gmatch() cant be nil) so I did "if (ITEMS_SETUP ~= nil) then...", now I can do the same with line 106, but anyway it should be fixed. At least change getuseroption() to return values like 0, "", false insted of nil.
    Last edited by Eldar; 12-07-2014 at 11:10 AM.

  4. #4
    Helper StaR's Avatar
    Join Date
    Dec 2013
    Location
    Manchester
    Posts
    713
    Reputation
    50
    Rep Power
    22
    For the sake of 3 heavy items you are over complicating things, you may as well have just had 3 setsettings ;o



  5. #5
    Free User Eldar's Avatar
    Join Date
    Dec 2013
    Posts
    2,385
    Reputation
    63
    Rep Power
    25
    Quote Originally Posted by StaR View Post
    For the sake of 3 heavy items you are over complicating things, you may as well have just had 3 setsettings ;o
    It doesnt matter, action working good, there is problem with getuseroption().

  6. #6
    Banned
    Join Date
    Nov 2014
    Location
    Madrid, Spain
    Posts
    250
    Reputation
    7
    Rep Power
    0
    worked it out?¿

  7. #7
    Helper StaR's Avatar
    Join Date
    Dec 2013
    Location
    Manchester
    Posts
    713
    Reputation
    50
    Rep Power
    22
    Quote Originally Posted by Eldar View Post
    It doesnt matter, action working good, there is problem with getuseroption().
    This
    getuseroption("CapToDropHeavyLoot")

    Should be
    tonumber(getuseroption("CapToDropHeavyLoot"))

    As you are trying to return a number not a string.
    Last edited by StaR; 12-07-2014 at 01:57 PM.



  8. #8
    Free User Eldar's Avatar
    Join Date
    Dec 2013
    Posts
    2,385
    Reputation
    63
    Rep Power
    25
    Quote Originally Posted by StaR View Post
    This
    getuseroption("CapToDropHeavyLoot")

    Should be
    tonumber(getuseroption("CapToDropHeavyLoot"))

    As you are trying to return a number not a string.
    tonumber(nil) is still nil.

  9. #9
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,441
    Reputation
    309
    Rep Power
    28
    I've been unable to reproduce the issue with the following code:

    auto(10)

    if getuseroption('test') == nil or getuseroption('test2') == nil then
    printerror('Fuck')
    else
    --print(os.clock(), 'ok')
    end


    Code:
    {
    	"type"     : "group",
    	"name"     : "Test",
    	"children" : [
    		{
    			"type"        : "lineedit",
    			"name"        : "test",
    			"text"        : "Test:",
    			"description" : "Test",
    			"value"       : ""
    		},
    		{
    			"type"        : "spinbox",
    			"name"        : "test2",
    			"text"        : "Test2"
    		}
    	]
    }
    It ran for about 30 minutes without issuing an error. If sometimes is more rarely than once every 180k tries, please let me know and I'll try some more exhaustive tests.
    Otherwise, please send me the complete .XML file you're having issues with, preferable the version where the error does happen. You can do it through PM if you wish, although I'd rather have it on my email: r.mobis@gmail,com.

  10. #10
    Free User Eldar's Avatar
    Join Date
    Dec 2013
    Posts
    2,385
    Reputation
    63
    Rep Power
    25
    Quote Originally Posted by Raphael View Post
    I've been unable to reproduce the issue with the following code:

    auto(10)

    if getuseroption('test') == nil or getuseroption('test2') == nil then
    printerror('Fuck')
    else
    --print(os.clock(), 'ok')
    end


    Code:
    {
    	"type"     : "group",
    	"name"     : "Test",
    	"children" : [
    		{
    			"type"        : "lineedit",
    			"name"        : "test",
    			"text"        : "Test:",
    			"description" : "Test",
    			"value"       : ""
    		},
    		{
    			"type"        : "spinbox",
    			"name"        : "test2",
    			"text"        : "Test2"
    		}
    	]
    }
    It ran for about 30 minutes without issuing an error. If sometimes is more rarely than once every 180k tries, please let me know and I'll try some more exhaustive tests.
    Otherwise, please send me the complete .XML file you're having issues with, preferable the version where the error does happen. You can do it through PM if you wish, although I'd rather have it on my email: r.mobis@gmail,com.
    It happen rather at the start of script or when I editing code of other actions, one time happend when I relog to other char. Its hard to test, I tried to check out when it happen, but its always unexcepted xD Im pretty sure Im right, not only I have this problem, also @Hagi has the same problem. If you want to test it check my free scripts, it happen in all of them (except elves). Check getuseroption("HeavyItems") and getuseroption("CapToDropHeavyLoot"), I dont know why, but only those 2 functions bugging.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •