Author Topic: Lydaan's Snippets  (Read 5163 times)

0 Members and 1 Guest are viewing this topic.

Offline lydaanTopic starter

  • Jr. Member
  • **
  • Posts: 70
  • Activity:
    0%
  • Reputation Power: 3
  • lydaan has no influence.
  • Respect: +6
  • Referrals: 0
    • View Profile
Lydaan's Snippets
« 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.

Works fine as a stand-alone sub, and updated it to handle single line as well as multi-line properties.

*edit: stripped this down to it's smallest form. it will hang if called with an invalid [Parameter_1] or if you die, etc. If you need help with adapting the wait conditions, let me know.

Description and parameters:
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.
;-------------------------------------------------------
; %1 = id of item to get property of, must not be null
;=======================================================
Examples calls:
Code: [Select]
...
goSub getProperty %thisThing
finditem %theseThings * c
for #findindex 1 #findcnt
{
   goSub getProperty #findID
   ...
}
goSub getProperty ABCDEFG
...

Sub:
Code: [Select]
sub getProperty
   set %gp_lpcReturn #lpc
   set #lpc 100
   event property n/a   ;sets #property = $
   while #property <> $ ;waits for #property = $ before moving on
      wait 
   event property %1
   while #property = $  ;waits for #property to update with the passed [Parameter_1]
      wait
   set #lpc %gp_lpcReturn
return

*edit: shaved a couple lines with repeat instead of while - Changed the name, fixed typos, added examples.

*edit: stripped it down to it's simplest form while still setting #lpc = 100. It also now works for single line as well as multi-line properties.

I will post it again as a semi-standalone with sub conCheck and sub login once I get all the subs worked out for Sub ClientAction.
« Last Edit: September 17, 2021, 05:15:05 PM by lydaan »

Tags: event property