Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Looting items - Page 2
Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Looting items

  1. #11
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    I already am. Should I add a reference to it or just use Imports System.Linq?
    Nvm, you can't add a reference to it.
    Last edited by poopsiedoodle; 09-30-2013 at 12:41 PM.

  2. #12
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    It's not a problem with referencing the LINQ library. It's just how listbox items are stored. Try this:
    Code:
    Dim lootItem as LootItem = ListBox3.Items.ToList().Where(Function(x) x.Text = loot.Id).FirstOrDefault()

  3. #13
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    I'll try it as soon as I get home from school.

    EDIT:
    Code:
    Error	1	'ToList' is not a member of 'System.Windows.Forms.ListBox.ObjectCollection'.	C:\Documents and Settings\matt and steve\My Documents\Downloads\Bot (1)\Bot\Bot\Form2.vb	471	44	Bot
    Last edited by poopsiedoodle; 09-30-2013 at 08:23 PM.

  4. #14
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    Quote Originally Posted by poopsiedoodle View Post
    I'll try it as soon as I get home from school.

    EDIT:
    Code:
    Error    1    'ToList' is not a member of 'System.Windows.Forms.ListBox.ObjectCollection'.    C:\Documents and Settings\matt and steve\My Documents\Downloads\Bot (1)\Bot\Bot\Form2.vb    471    44    Bot
    I apologize, this is what I get for not having access to VB and trying to type from memory on my cellphone. See if this will work:
    Code:
    Dim lootItem as LootItem = ListBox3.Items.OfType(Of LootItem)().FirstOrDefault(Function(x) x.Text = loot.Id)
    That should convert all the listboxitems to a list of LootItem objects. If that doesn't work, I'll have to give it a shot once I'm in front of my computer and can access VB.

  5. #15
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    Quote Originally Posted by Jo3Bingham View Post
    I apologize, this is what I get for not having access to VB and trying to type from memory on my cellphone. See if this will work:
    Code:
    Dim lootItem as LootItem = ListBox3.Items.OfType(Of LootItem)().FirstOrDefault(Function(x) x.Text = loot.Id)
    That should convert all the listboxitems to a list of LootItem objects. If that doesn't work, I'll have to give it a shot once I'm in front of my computer and can access VB.
    Well, there aren't any errors with that, just the same warning I have with the attacker (before and after your new code) which is
    Code:
    Warning	2	Using the iteration variable in a lambda expression may have unexpected results.  Instead, create a local variable within the loop and assign it the value of the iteration variable.
    but that hasn't caused any problems, so meh.

  6. #16
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    Quote Originally Posted by poopsiedoodle View Post
    Well, there aren't any errors with that, just the same warning I have with the attacker (before and after your new code) which is
    Code:
    Warning    2    Using the iteration variable in a lambda expression may have unexpected results.  Instead, create a local variable within the loop and assign it the value of the iteration variable.
    but that hasn't caused any problems, so meh.
    I forgot about that little warning with lambda expressions... You can solve it by setting 'loot' to a variable before the line above (Dim lootItem As LootItem...) and then reference that variable instead of loot.

    Code:
    Private Sub LootItems()
        For Each body As Container In inventory.GetContainers().Where(Function(x) x.Name.ToLower().StartsWith("dead ") Or x.Name.ToLower().StartsWith("remains ") Or x.Name.ToLower().StartsWith("slain "))
            For Each loot As Item In body.GetItems()
                Dim thisLoot As Item = loot
                Dim lootItem As LootItem = ListBox3.Items.OfType(Of LootItem)().FirstOrDefault(Function(x) x.Text = thisLoot.Id)
                If lootItem IsNot Nothing Then
                    lootBP = inventory.GetContainers().FirstOrDefault(Function(x) x.Name = lootItem.BP)
                    If lootBP IsNot Nothing Then
                        lootItem.Move(lootBP.GetItems().First().Location)
                    End If
                End If
            Next
        Next
    End Sub

  7. #17
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    well, it still loots stuff, so I don't think there'd be too much point in changing it :P
    Now I just have to figure out a way to put the body locating/opening code that I wrote in there.

  8. #18
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    Ok, so, my function for opening bodies is not working at all. LootItems() is working though. Here's what I have:

    Code:
    Private Function openbodies()
            My.Settings.deadlocs.Clear()
            For Each dead As Creature In c.BattleList.GetCreatures
                If dead.HPBar = 0 Then
                    My.Settings.deadlocs.Add(dead.Location.ToString)
                    For Each bodyloc As String In My.Settings.deadlocs
                        For Each square As Tile In c.Map.GetTiles
                            If square.Location.ToString = bodyloc Then
                                For Each deadbody As Item In square.Items
                                    If deadbody.Name.Contains("Dead") Or deadbody.Name.Contains("Slain") Or deadbody.Name.Contains("Remains") Then
                                        p.Walk(bodyloc)
                                        c.Inventory.UseItemOnTile(deadbody.Id, square)
                                        Lootitems()
                                    End If
                                Next
                            End If
                        Next
                    Next
                End If
            Next
            Return True
        End Function
    
        Private Function Lootitems()
            
    
            For Each body As Container In inventory.GetContainers().Where(Function(x) x.Name.ToLower().StartsWith("dead ") Or x.Name.ToLower().StartsWith("remains ") Or x.Name.ToLower().StartsWith("slain "))
                For Each loot As Item In body.GetItems()
                    Dim lootItem As LootItem = ListBox3.Items.OfType(Of LootItem)().FirstOrDefault(Function(x) x.Text = loot.Id)
                    If lootItem IsNot Nothing Then
                        Dim lootBP = inventory.GetContainers().FirstOrDefault(Function(x) x.Name = lootItem.BP)
                        If lootBP IsNot Nothing Then
                            loot.Move(lootBP.GetItems().First().Location)
                        End If
                    End If
                Next
            Next
    
    
            Return True
        End Function

Posting Permissions

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