View unanswered posts | View active topics It is currently Thu Apr 24, 2014 2:30 pm



Reply to topic  [ 1 post ] 
Using typFind to ease extension interoperability 
Author Message
Militia Commander
Militia Commander
User avatar

Joined: Sun Nov 07, 2010 10:20 pm
Posts: 311
Location: . . . between the stars and the warm black sky . . .
Post Using typFind to ease extension interoperability
Hi! Quick little fun trick I found out about. (typFind (cat "* +unid:" &someUnid;)) returns a list containing only the unid you gave it if the type that that unid represents exists in the current game environment, or 'nil' if it does not.

You can't do this check in <Globals> because it's likely not all types have been defined yet, but you can do it from a run-once event a-la:

Code:
<StationType unid="&stWhatever;" virtual="True">
  <Events>
    <OnGlobalPlayerEnteredSystem>
      (block nil
        (if (not (typIncGlobalData &stWhatever; 'done 1)) (block nil
          (setq myGlobalUnidList (filter myGlobalUnidList unid (typFind (cat "* +unid:" unid))))
        ))
      )
    </OnGlobalPlayerEnteredSystem>
  </Events>
</StationType>

(myGlobalUnidList to be supplied by reader)

Filter works here without opening the returned list because of two things:
  • A list with any items in it counts as a true value when given to something requiring a boolean input
  • An empty list or nil, which are actually interchangeable, count as a false value when ....

_________________
Image
Image
Image


Sat May 26, 2012 11:37 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.