Author Topic: FindItem timer  (Read 2471 times)

0 Members and 1 Guest are viewing this topic.

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
FindItem timer
« on: August 31, 2013, 03:54:34 PM »
0
Good day
  I'm trying fixing a snippet of mine  Do i need to add a wait in between those finditem  or this is how is should be. 
Code: [Select]
if if #weight >= %mxwt
   return #true
FindItem %item C_ , #backpackid
if #FINDCNT > 0
   gosub moveitem
FindItem %item C_ , %itembox
if #FINDCNT > 0
   gosub makeitem

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: FindItem timer
« Reply #1 on: August 31, 2013, 06:05:19 PM »
0
Nope, no wait necessary.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: FindItem timer
« Reply #2 on: August 31, 2013, 06:33:39 PM »
0
Thx TM
 here a new one.  Can I make this faster.

Code: [Select]
sub move item
finditem %item C_ , #backpackid
exEvent Drag #findID %stack
exevent dropc %itembox
wait 20
if #FindCnt > 0
   gosub moveitem
return #true

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: FindItem timer
« Reply #3 on: August 31, 2013, 10:30:16 PM »
0
Code: [Select]
sub move item ;<--- Sub Names can't Contain Spaces.This would be "Sub Move"
finditem %item C_ , #backpackid
exEvent Drag #findID %stack
exevent dropc %itembox
wait 20
if #FindCnt > 0
   gosub moveitem ;<-- Would go nowhere. 
return #true

Its also fairly risky to do a gosub to a sub, inside a sub. Was just picking TM's brain on this one. You can wind up with an infinite Loop, and Variable Crossover. A better method would probably be a "For" Loop so you can have a fail safe.

Code: [Select]
Sub MoveItem
For %Attempt 1 5 ; Limit of 5 Tries
{
Finditem %Item C_ , #backpackid
if #FIndcnt > 0
{
Exevent Drag %Item #Findstack
Exevent dropc %itembox
wait 20
}
if #Findcnt = 0
Break ; Breaks from the For Loop, just ends it a little quicker
}
Return
Then at the End of the For Loop, you could do 1 final check, and if the item still hasn't moved, do a "Reset" Close the backpack and reopen it. Normally its either a glitched Item, or You Con lossed or some thing along those lines.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: FindItem timer
« Reply #4 on: September 01, 2013, 07:58:20 AM »
0
Thx Manwinc,  Thx for the exemple.
      Just notice that I copy an old sub :(  This is the one I'm using now.   
Code: [Select]
sub MoveItem
finditem %Item C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
exEvent Drag #findID   ;  %stack
exevent dropc %itembox
wait 20
}
return #true

Right now the item are moving every 2 sec and wondering if we can make them move faster.   
Can add the namespace push help me gain some speed.
Code: [Select]
sub MoveItem
  namespace push
  namespace local MI
finditem %Item C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
exEvent Drag #findID   ;  %stack
exevent dropc %itembox
wait 20
}
namespace pop
return #true

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: FindItem timer
« Reply #5 on: September 01, 2013, 09:23:10 AM »
0



Namespace Push Just puts Your Last namespace into a "Save", so when you do Namespace POP, it reloads the Namespace.

Code: [Select]
Namespace Local MW_Test
Display Your Namespace is #NSNAME
Namespace Push ; <- Saves the Previous NameSpace
Namespace Local MW_Next
Display Your Namespace is #NSNAME
Namespace Pop ;<- Reloads MW_Test
Halt

Namespaces Are for "Subs" that you want to be able to use without Interfering with the % Variables of your Script and to Communicate Between Scripts running under the same thread.

Code: [Select]
sub MoveItem
  namespace push
  namespace local MI
finditem %Item C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
exEvent Drag #findID   ;  %stack
exevent dropc %itembox
wait 20
}
namespace pop
return #true

If you do a for #Findindex 1 #Findcnt, its always important to make sure that an item actually exists.

Code: [Select]
Finditem %Item C_ , #Backpackid
if #Findcnt > 0
{
For #Findindex 1 #FIndcnt
{
Exevent Drag #Findid ; Stack
Exevent Dropc %ItemBox
wait 20
}
}

If you wanted to make this into a Sub you could use in any situation, this is one way to set it up.

Code: [Select]
Sub MoveItem
Namespace Push
Namespace Local Ghost_MoveItem ;<- Unique name, This is handy because you can tell when your script is where by #Nsname
set !Itemid %1
set !Amount %2
set !ItemBox %3 ; ! Variables Are Unique to the NameSpace
Finditem !Itemid C_ , #backpackid
if #Findcnt > 0
{
Exevent drag !ItemID !Amount
Exevent Dropc !ItemBox
Wait 20
}
NameSpace Pop
Return

When you wanted to use that Sub you would do

Gosub MoveItem (ID) (Amount) (Drop Bag ID)
« Last Edit: September 01, 2013, 09:36:00 AM by manwinc »
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Grandewd

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Re: FindItem timer
« Reply #6 on: September 16, 2013, 11:17:20 AM »
0

@manwinc ^^^^^^

Great, simple example of namespace usage.... Thx  ;)

Tags: