Author Topic: Lydaan's Snippet(s ... I hope :P )  (Read 1645 times)

0 Members and 1 Guest are viewing this topic.

Offline lydaanTopic starter

  • Jr. Member
  • **
  • Posts: 55
  • Activity:
    0%
  • Reputation Power: 2
  • lydaan has no influence.
  • Respect: +4
  • Referrals: 0
    • View Profile
Lydaan's Snippet(s ... I hope :P )
« on: March 04, 2016, 05:42:46 AM »
+1
My first snippet! :D Everyone's favorite, Event Property!

After much much reading and many hours working with event property, I finally came up with a way to evaluate event property to make sure that it is current for the item in question. Enjoy, and criticize freely! This should only stall if you use it incorrectly.

Code: [Select]
;=======================================================
;       -=| Lydaan's GetProperty Sub |=-
; --- For when event property is your only option ---
;     Ensures #property is current for the item
;     in question while taking the minimal amount
;     of time. No extra wait needed.
;             ***DISCLAIMER***
;     Only works with multi-line object
;     properties. If you need single line
;     support, you're doing it wrong.
;-------------------------------------------------------
; %1 = id of item to get property of, must not be null
;=======================================================

; Examples:
...
goSub getProperty %thisThing
finditem %theseThings * c
for #findindex 1 #findcnt
{
   goSub getProperty #findID
   ...
}
goSub getProperty ABCDEFG
...

sub getProperty
   set !lpc #lpc
   set #lpc 100
   event property null ; sets #property = $
   while #property <> $ && #charghost = no
      wait 0 ; ensures #property = $ beofore moving on, while not dead
   repeat
      event property %1 ; event property of the passed item, duh
      str count #property $ ; ensures #property updates with more than just the title
   until #strres > 1 || #charghost <> no
   set #lpc !lpc
return

*edit shaved a couple lines with repeat instead of while - Changed the name, fixed typos, added examples
« Last Edit: March 05, 2016, 05:10:42 PM by lydaan »

Tags: event property