What I have in mind: a Loot Scanner that will notify you about shipwrecks that are worth docking with.
Between the mining scanners and looting autons, I don't think this will require too much original work.
Which brings me to question #1: is it okay to reuse other people's code without asking?
Next, as I don't think I'll get things right on the first try: how does one go about debugging?
Does Transcendence provide useful error messages or, well... I have no idea what I could do if it doesn't.
Finally, is there a way for me to get this working in my current game? Like, hijacking and extending the
mining scanner I'm currently employing? I don't want to start over and frankly, I'll only try to get this started
if I can expect to use it right away.
a looting mod & several questions
-
- Fleet Admiral
- Posts: 2876
- Joined: Thu Feb 03, 2011 5:21 am
- Location: Hmm... I'm confused. Anybody have a starmap to the Core?
It's best to ask first through a PM on the forums (as I have), but if the user is long gone, wait a while for a reply before you use it. I think the original modder can still ask for you to remove the offending code if it's misused.Schnobs wrote:Which brings me to question #1: is it okay to reuse other people's code without asking?
To debug, you could use the dbglog function, but it's best to learn the simple stuff (xml) before going on to tscript, unless you know another language first.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
Get on Discord for mod help and general chat
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
-
- Militia Captain
- Posts: 779
- Joined: Wed Nov 18, 2009 1:01 am
- Location: Still looking for the csc Antarctica
- Contact:
(dbglog) is your friend, use it ever other line if you want to know where something is breaking, trust me on that, I have done it!
irc is the best place to learn to code, there are almost always a experienced coder online, and if you hang around for while, someone will answer your questions.
irc is the best place to learn to code, there are almost always a experienced coder online, and if you hang around for while, someone will answer your questions.
"Dash_Merc - George is a genius, in that he created this game engine that is infinitely extendable"
"<@sheepluva>Good night everybody, may the source be with you." <-- FOSG dev
"You only need THREE tools in life - WD-40 to make things go, Duct Tape to make things stop And C-4 to make things go away"
- alterecco
- Fleet Officer
- Posts: 1658
- Joined: Wed Jan 14, 2009 3:08 am
- Location: Previously enslaved by the Iocrym
A lot of modders have already given free access to their code. So, as long as you don't copy a mod wholesale and claim it is yours, you should be ok. If you have been heavily inspired by another mod, then give credit where it is due, and you should be ok as well :)
-
- Fleet Officer
- Posts: 1533
- Joined: Tue Mar 22, 2011 8:43 pm
- Location: Alaska
- Contact:
Your shipwreck notification is cool : but I was thinking that it might be calling the OnUpdate for looping the system for wrecks will call too much ( considering the system and what goes in a given system, like a binary has alot going on for updates. )alterecco wrote:A lot of modders have already given free access to their code. So, as long as you don't copy a mod wholesale and claim it is yours, you should be ok. If you have been heavily inspired by another mod, then give credit where it is due, and you should be ok as well
George did say : " use OnUpdate sparingly " so this is what I think you should keep in mind while you test your ideas.
As for what alterecco said : I would add to at least attempt to PM the extension maker : and/or post for input on what your going to use in the drawing board : so if there is a "no" waiting to happen or the makers have changed names they can get the info and be shocked at your politeness of asking
Flying Irresponsibly In Eridani......
I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
I didn't even really try to get started... the code almost makes sense, but I can't really fathom the ramifications.shanejfilomena wrote: Your shipwreck notification is cool : but I was thinking that it might be calling the OnUpdate for looping the system for wrecks will call too much
Here's a snippet from the "Prospector" ore scanner I use and what I think it means:
Code: Select all
<Events>
<OnUpdate>
(if (and (or (eq gSource gPlayerShip) # the first three lines seem to deal with wether I may scan at all
(and (not (objIsEnemy gSource gPlayerShip)) # but I don't quite get what it's really checking
(eq (objGetOrderGiver gSource) gPlayerShip))) # also, syntax / indentation seems quite weird
(filter (objGetItems gSource "cI") itm (eq (itmGetType itm) &itMinersCargoHold;)))
#
# The above is true if ( (gSource == gPlayerShip) OR (the next two conditions are both true) ) AND ( I have the necessary equipment)
#
(block (roids)
(setq roids (filter
(sysFindObject gSource "t +asteroid; N:16;") # find asteroids in range (16 lightseconds, I presume)
roid
(gr (count (objGetItems roid "t +Ore;")) 0))) # all further tests apply only to rocks in scanner range
Anyway, back to topic: I don't quite know how "OnUpdate" works, but this function looking for rocks in range works well on my oldish machine.
Assuming that you'll only rarely end up with as many shipwrecks as there are rocks in a mid-sized asteroid belt, I'm not worried about CPU time.
On the other hand, the actual checks to be performed on the wrecks-in-range would be a bit more complicated, and you could end up with quite a few wrecks in a dense cluster.
- alterecco
- Fleet Officer
- Posts: 1658
- Joined: Wed Jan 14, 2009 3:08 am
- Location: Previously enslaved by the Iocrym
Your analysis is quite spot on. Indeed, the indenting could have been a bit better in that example. The best place to see what functions are, is on xelerus.de. In this case, 'gr' is 'greater than'. gSource and gPlayerShip are global variables (therefore the 'g'). gSource always points to the object the event is running on. So, say I have an OnUpdate on the playership: Then gPlayerShip would equal gSource. It is also often used in Dock Screens to signify the station showing the screen. You should not be worried about CPU time of OnUpdate unless you are doing something crazy in it or have it placed on some item that is spawned very many times.
For general help with 'silly questions' there really is no better place than IRC. We are a quite active modding community there, and I am sure you would feel welcome.
For general help with 'silly questions' there really is no better place than IRC. We are a quite active modding community there, and I am sure you would feel welcome.
-
- Fleet Admiral
- Posts: 2876
- Joined: Thu Feb 03, 2011 5:21 am
- Location: Hmm... I'm confused. Anybody have a starmap to the Core?
Also, to add what 'ecco said, there's also a decent events page on the wiki. It has most documented global variables there.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
Get on Discord for mod help and general chat
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
yep, http://wiki.neurohack.com/transcendence ... xml/events -- someone on IRC tossed that at me.
Which brings me to
I wonder why the tests were considered necessary.
If I understand it correctly, OnUpdate is tied to a specific item anyway. There might be any number of OnUpdates for any number of items, but each OnUpdate event, when it happens, refers to a particular item. In our case, (eq gItem itMinersCargoHold) and (eq gSource gPlayerShip) would both be true by definition. Why test them?
Or rather: what did I get wrong?
Which brings me to
Looking at the code again...wiki/events wrote: <OnUpdate>
Populated variables:
gSource: object that carries the item
gItem: the item
Code: Select all
<OnUpdate>
(if (and (or (eq gSource gPlayerShip)
(and (not (objIsEnemy gSource gPlayerShip))
(eq (objGetOrderGiver gSource) gPlayerShip)))
(filter (objGetItems gSource "cI") itm (eq (itmGetType itm) &itMinersCargoHold;)))
If I understand it correctly, OnUpdate is tied to a specific item anyway. There might be any number of OnUpdates for any number of items, but each OnUpdate event, when it happens, refers to a particular item. In our case, (eq gItem itMinersCargoHold) and (eq gSource gPlayerShip) would both be true by definition. Why test them?
Or rather: what did I get wrong?
- WillyTheSquid
- Militia Lieutenant
- Posts: 195
- Joined: Wed Jan 18, 2012 4:32 pm
- Location: Rotterdam, The Netherlands
As far as I'm concerned, you can use the mining scanner code, but it's TransGeek's work so you might wanna check with him.
Lootscanner for the win
Lootscanner for the win
“Normal people believe that if it ain't broke, don't fix it. (Modders) believe that if it ain't broke, it doesn't have enough features yet.” -Scott Adams
Resident mod-cobbler-together, freakspawn-fixer-upper & musical eclectro-ecumenologist.
If you love something, tweak it and twist it. Keep bending it until it breaks. Rip it apart, remix it, rebuild it. Kill your darlings and stitch them together again.
JOIN US ON IRC. IT KICKS ASS. JOIN THE HIVE MIND.
Place cursor on link. Click link. Never look back.
- alterecco
- Fleet Officer
- Posts: 1658
- Joined: Wed Jan 14, 2009 3:08 am
- Location: Previously enslaved by the Iocrym
One could imagine a scenario where a cargo hold ended up on an enemy AI ship. I seems to me that the Prospector is installable on a wingman, perhaps through UGWingmen or some similar mod use.Schnobs wrote: I wonder why the tests were considered necessary.
If I understand it correctly, OnUpdate is tied to a specific item anyway. There might be any number of OnUpdates for any number of items, but each OnUpdate event, when it happens, refers to a particular item. In our case, (eq gItem itMinersCargoHold) and (eq gSource gPlayerShip) would both be true by definition. Why test them?
For a simpler use case one could probably get away with something like the following:
Code: Select all
<OnUpdate>
(if (and (eq gSource gPlayerShip)
(itmIsInstalled gItem))
(block nil
;; your code here
)
)
</OnUpdate>
OK, so it might be elsewhere, I get that.alterecco wrote: For a simpler use case one could probably get away with something like the following:
But one needs to check wether it's installed? Does that mean OnUpdate is called regularly as long as the item exists, even if it's just sitting in my cargo hold (or some shop)?
And while I'm at it, the next one (this is a little like pronouncing every single letter as my finger slides across the page):
This is pretty much copy/paste... so it ought to work, but I don'k now why.
Code: Select all
(block (wrecks) ; I don't quite get why I need this at all.
(setq wrecks ; create a listnamed "wrecks"
(filter (sysFindObject gSource "tM -populated; N:25") wreck ; populate the list with wrecks-in-range...?
The (sysFindObject ...) is wrecks-in-range. This is the list I'll work with next.
(filter ... wreck (stuff)) opens a FOR loop, with "wreck" being the temporary handle for every wreck-in-range while I do (stuff).
So basically,
"for WRECK in (get wrecks-in-range) do (stuff)" -- note that (stuff) isn't in the example.
Sounds simple enough once got my head around it. It just took me quite a while to see it that way.
No please tell me that I'm right.
Other than that, I want this to work only on shipwrecks, not stations. Is there away to distinguish between the two?
- alterecco
- Fleet Officer
- Posts: 1658
- Joined: Wed Jan 14, 2009 3:08 am
- Location: Previously enslaved by the Iocrym
Yep, iirc.Schnobs wrote:Does that mean OnUpdate is called regularly as long as the item exists, even if it's just sitting in my cargo hold (or some shop)?
A short explanation... hope it clarifies. But yeah, basically you are right.Schnobs wrote:And while I'm at it ...snip...
Code: Select all
(block (wrecks) ;; this defines 'wrecks' as a variable local to the block (otherwise it would be global!)
(setq wrecks ;; actually set the variable
(filter .... ;; loops over every element in a list and returns a new list with every element that the "stuff" expression returned true for
Not in any easy way... at least there is no (objIsWreck ....) function :/Schnobs wrote:Other than that, I want this to work only on shipwrecks, not stations. Is there away to distinguish between the two?
Last i did this (and this is years ago), i checked if the visible damage of an object was 100, or if its name included the string "wreck". We might have gotten an attribute since then, but I am not sure.
Here is the check i used:
Code: Select all
(or (eq (objGetVisibleDamage obj) 100) (strFind (objGetname obj) "wreck"))
Wrecks are not active. That's something you can check for in the criteria string for sysfindobject.
Criteria are kind of messy. See http://wiki.neurohack.com/transcendence ... t_criteria.
Criteria are kind of messy. See http://wiki.neurohack.com/transcendence ... t_criteria.
Literally is the new Figuratively
Nah, I meant only shipwrecks, not stationwrecks. Both are wrecks and inactive and everything... anyway, that's cosmetic.Atarlost wrote:Wrecks are not active. That's something you can check for in the criteria string for sysfindobject.
I now tried my code for the first time and guess what? It doesn't work.
I attached it to the ore scanner, like this:
Code: Select all
(if we may scan
(scan asteroids for ore)
(scan wrecks for loot)
)