Results 1 to 3 of 3

Thread: case sensitive when pulling items from bag

  1. #1

    case sensitive when pulling items from bag

    I have a lot of items in a bag and use scripting with an input field to pull items out by name. In its current form it seems to be case sensitive. Is there a tweak I can make to the script to have it not care about upper and lower case letters?

    Script on the bag containing the items:
    Code:
    function onload()
      createInput()
      createButton()
      self.interactable = false
    end
    
    function createInput()
    self.createInput({
      input_function = "doNothing",
      label = "Tile #",
      function_owner = self,
      alignment      = 3,
      position       = {0,4.1,1},
      width          = 2000,
      height         = 850,
      font_size      = 650,
      color          = {1,1,1},
      font_color     = {0,0,0},
      value = ""
      })
    end
    
    
    function doNothing() end
    
    function onObjectLeaveContainer(container, obj)
        if container == self then
            local objClone = obj.clone({position = self.getPosition()})
            self.putObject(objClone)
        end
    end
    
    
    function createButton()
      self.createButton({
        click_function = "get_Tile",
        function_owner = self,
        label = "Place Tile",
        position = {0, 4.1, -2},
        width = 3300, height = 1050, font_size = 800, color = {1,1,1}, font_color = {0,0,0}
      })
    end
    
    function get_Tile()
      local inputs = self.getInputs()
      local objectsInBag = self.getObjects()
      for i, v in pairs(inputs) do
        search_param = v.value
      end
      for _, card in ipairs(objectsInBag) do
        if card.nickname == search_param then
          self.takeObject({position = {-20.19, 5, 18.65}, guid = card.guid})
        end
      end
    end

  2. #2
    If "card.nickname" and "search_param" are the strings you compare, you can do

    Code:
    if card.nickname:lower() == search_param:lower() then
    for a case insensitive compare (str:lower() returns str with all characters lowercased).

  3. #3
    Thanks a bunch!

Similar Threads

  1. Replies: 4
    Last Post: 11-09-2018, 04:40 PM
  2. Duplicate items
    By Phase in forum Bug Reports
    Replies: 0
    Last Post: 05-05-2018, 02:43 PM
  3. Pulling items from a bag based from posted list
    By CrazyVulcan in forum Scripting
    Replies: 18
    Last Post: 03-26-2018, 02:47 PM
  4. [SOLVED] The Mysterious Case of the Disappearing Go Stone
    By aaronbpaden in forum Technical Support
    Replies: 1
    Last Post: 11-04-2015, 12:04 PM
  5. Grab all the items from bag
    By Mexzord in forum Suggestions
    Replies: 2
    Last Post: 04-14-2015, 11:07 AM

Posting Permissions

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