Yes, if it's showing up something's bad. Can you paste the code? If it is what you posted, you would get an error saying that "we" is not a proper function.
I'll post some code when I get to a computer.
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?
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.
Don't be silly -- the "code" in my last post is no actual code, I thought that was obviuos. It's just meant to illustrate how and where I pieced it into an already-enabled extension.RPC wrote:Yes, if it's showing up something's bad. Can you paste the code? If it is what you posted, [...]
As to my actual code, I don't ask you (or anybody) to debug it for me: doing it myself is part of the deal. I just don't quite know how to get started with debugging. Anyway, here it comes:
Code: Select all
(block (wrecks loot_ok it)
(setq wrecks
(filter (sysFindObject gSource "tM -populated; N:25") ; give me all wrecks in range, filter runs only against that limited number
wreck ; for every wreck, do
(enumWhile (objGetItems wreck "*") loot_ok it ; get all items in hold -- loot_ok=True/NIL it=items
(block (price vpt) ; here come the actual tests for "filter" ---- vpt=value_per_ton
(setq price (divide (itmGetActualPrice it) (if (itmIsDamaged it) 2 1))) ; get price, damaged items at half value
(setq vpt (divide (multiply price 1000) (itmGetMass it))) ; caculate vaue_per_ton
(setq loot_ok (gr vpt 500)) ; set threshold here
;
; this is a bit silly: if vpt is high enough, loot_ok will be set to NIL
; however, NIL is needed to break the loop
; we want to break, because:
; a single worthy item is enough, no need to check the rest
;
(if (and value_ok (shpIsFuelCompatible it)) setq (value_ok NIL))) ; we always want usable fuel, regardless of vpt
; remember, value_ok=TRUE if the value is *not* ok (I should find a better name)
; TODO: add further tests here
; like, ammo for installed weapons
) ; this closes "enumWhile"
) ; this closes filter, now "wrecks" is populated -- or not.
(if (gr (count wrecks) 0) ; if the list if of non-zero size
(enum wrecks wreck ; split it into chunks and
(sysCreateEffect &oreShockwave; wreck (objGetPos rock)) ; make each wreck blink
)
)
)
)
-
- Fleet Officer
- Posts: 1533
- Joined: Tue Mar 22, 2011 8:43 pm
- Location: Alaska
- Contact:
Just not to be annoying: but probably is because your just testing :Schnobs wrote:Thanks!alterecco wrote:You need to set loot_ok to true initially. Your item enumWhile never runs because of that I would think.
That's not the only problem, but one I'd never have spotted. Although in hindsight.... <facepalm>
but I think 25 is way too short: you would basically be parked next to it.
I think 180 works fine and I experimented with other numbers in the past: but 180 the engine likes :
I don't know why: it just works better for me.
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..
No worries: N:25 gets to the edge of the screen, though only barely, and it doesn't reach into the corners.shanejfilomena wrote: Just not to be annoying: but probably is because your just testing :
but I think 25 is way too short: you would basically be parked next to it.
Pushing this up to 40 would cover every visible wreck -- any more would be a waste of CPU cycles.
Depending on the situation, you might still want a means to scuttle wrecks.
Guess I've been too smart for my own good:
Next I go over all items in a wreck, assigning "donotloot=True/Nil" depending on some criteria.
This works, I can see it work on the debug console. However, it does not function as a filter:
As long as there's anything in the hold, the wreck will be added to the "worthy_wrecks" list.
Why is this so?
Code: Select all
(setq worthy_wrecks
(filter near_wrecks wreck
(block (donotloot)
(setq donotloot TRUE)
(enumWhile (objGetItems wreck "*") donotloot it
This works, I can see it work on the debug console. However, it does not function as a filter:
As long as there's anything in the hold, the wreck will be added to the "worthy_wrecks" list.
Why is this so?
-
- Fleet Officer
- Posts: 1533
- Joined: Tue Mar 22, 2011 8:43 pm
- Location: Alaska
- Contact:
Loot Auton : http://xelerus.de/index.php?s=mod&id=218Schnobs wrote:Guess I've been too smart for my own good:
Next I go over all items in a wreck, assigning "donotloot=True/Nil" depending on some criteria.Code: Select all
(setq worthy_wrecks (filter near_wrecks wreck (block (donotloot) (setq donotloot TRUE) (enumWhile (objGetItems wreck "*") donotloot it
This works, I can see it work on the debug console. However, it does not function as a filter:
As long as there's anything in the hold, the wreck will be added to the "worthy_wrecks" list.
Why is this so?
this auton's code should give you more of a working idea you need to filter things out with and how insane it will drive you to build the filter for how you would like it to be ( as in working / worthy and detailed ) you can order the looting of only fuel if you want
Sometimes : there are only so many ways to go " BOOM " : communicate with the author of the Auton if you can not figure out a way to adapt the code : sometimes, they have seen a easier way after they spent weeks driving themselves nuts making it work .
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 think I solved the enumWhile riddle:
Will return item, item, item until something sets "donotloot" to NIL, thus breaking the loop.
Even if the loop breaks on the first run, it will still return one item.
A list of one item is decidedly not empty, the filter sees this as TRUE. That way, every weck with any item on board will pass the filter.
I tried (if donotloot (setq it Nil)) at the very end of the enumWhile loop, but that made the scanner work in reverse, only flagging worthless wrecks. I have no idea why. Interestingly, it needs to be at the very end of the loop. If I do as much as adding another (dbgOutput "blah") afterwards, the Nil will have no effect whatsoever.
Code: Select all
(filter near_wrecks wreck
[...]
(enumWhile (objGetItems wreck "*") donotloot it
Even if the loop breaks on the first run, it will still return one item.
A list of one item is decidedly not empty, the filter sees this as TRUE. That way, every weck with any item on board will pass the filter.
I tried (if donotloot (setq it Nil)) at the very end of the enumWhile loop, but that made the scanner work in reverse, only flagging worthless wrecks. I have no idea why. Interestingly, it needs to be at the very end of the loop. If I do as much as adding another (dbgOutput "blah") afterwards, the Nil will have no effect whatsoever.
Quoting myself, but hey:
Yes, "filter" accepts pretty much everything. Any string or list will be considered as TRUE, unless the string/list is empty, in which case it's NIL. The single most important thing I didn't get was that I shouldn't return the items, that the items really don't matter, that the only thing that counts is wether I return anything at all.
If anyone's interested, the full code can be found at http://paste.neurohack.com/view/YYvEG/
I'm not 100% confident yet, but it seems to work more often than not.
<buzz sound> WRONG! it shouldn't return items! It should return either True or Nil...Schnobs wrote:I think I solved the enumWhile riddle:
Will return item, item, item [...]Code: Select all
(filter near_wrecks wreck [...] (enumWhile (objGetItems wreck "*") donotloot it
Yes, "filter" accepts pretty much everything. Any string or list will be considered as TRUE, unless the string/list is empty, in which case it's NIL. The single most important thing I didn't get was that I shouldn't return the items, that the items really don't matter, that the only thing that counts is wether I return anything at all.
If anyone's interested, the full code can be found at http://paste.neurohack.com/view/YYvEG/
I'm not 100% confident yet, but it seems to work more often than not.
-
- Fleet Officer
- Posts: 1533
- Joined: Tue Mar 22, 2011 8:43 pm
- Location: Alaska
- Contact:
Schnobs wrote: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:Now, OnUpdate I get my code displayed on the screen. Is that alone a hint as to the nature of my mistake?Code: Select all
(if we may scan (scan asteroids for ore) (scan wrecks for loot) )
Code: Select all
<Events>
<Scan>
(block (asteroidList)
; (setq asteroidList (sysFindObject gSource "t +asteroid; N:90;"))
; (setq asteroidList (filter asteroidList asteroid (objGetItems asteroid "t +Ore;")))
(setq asteroidList (moeFineOre gSource 90))
(enum asteroidList asteroid (sysCreateEffect &efGoodgooblygoo; asteroid (objGetPos asteroid)))
(objSendMessage gPlayerShip Nil (cat "Detected "(count asteroidList) " ore bearing asteroids"))
)
</Scan>
</Events>
Code by Apemant : but there are only " so many " ways to do it so it works and they will essentially be replicants of Apemant' code.
If I am reading it right: your trying to lock on to if the item is on the playership?
go to the Dall Sphere : it has answers : make it sooooooooooo much easier and no errors.
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'm afraid I do not understand this, nor why you dug up that old example to do... what exactly?shanejfilomena wrote: go to the Dall Sphere : it has answers : make it sooooooooooo much easier and no errors.
Anyhoo, now you brought it up again, I might as well explain that bit as well:
This will dump lumps of text on the game screen:
Code: Select all
(if we may scan
(scan asteroids for ore)
(scan wrecks for loot)
)
Code: Select all
(if we may scan
(block Nil
(scan asteroids for ore)
(scan wrecks for loot)
))
-
- Fleet Officer
- Posts: 1533
- Joined: Tue Mar 22, 2011 8:43 pm
- Location: Alaska
- Contact:
The Dall Sphere is an Ancient Artifact : it hold many secrets,
I used it's teachings to stop players from running off with my bribe ....and my ships.
Obviously , if you 'have no use for common code' then you are into something that is going to take longer then the fuel tanks will hold for.
No fears : I live forever. I can wait.
I used it's teachings to stop players from running off with my bribe ....and my ships.
Obviously , if you 'have no use for common code' then you are into something that is going to take longer then the fuel tanks will hold for.
No fears : I live forever. I can wait.
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..
OK, no that I finished my game I can think about turning this into a "proper" mod, one that others can use...
I wonder how I can get it into the game. "onUpdate" requires some device or item to work from, right? But I don't want it to eat another device slot, that's for sure. Is it possible to make it a ROM? How?
I wonder how I can get it into the game. "onUpdate" requires some device or item to work from, right? But I don't want it to eat another device slot, that's for sure. Is it possible to make it a ROM? How?