Codemonkeys take heed! ;)

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Add a removeCargo-method as an inverse to awardCargo. I stumbled on that one yesterday during playtesting.

You can use awardCargo: with a negative number, but it is impracticable, as on my pretty fast computer (2 GHz Intel Core Duo) it takes about 15 seconds to process that command, and the fan went mad during that time! Here's a log-file-example from what I tried out yesterday. Have a look at the time-string at the beginning of each line:
2007-03-13 23:29:29.329 Oolite[1981] SCRIPT debug messages ON
2007-03-13 23:29:29.330 Oolite[1981] DEBUG ::::: scriptAction: "awardCargo: -10 Gold"
2007-03-13 23:29:29.330 Oolite[1981] DEBUG ::::: after expansion: "awardCargo: -10 Gold"
2007-03-13 23:29:29.330 Oolite[1981] DEBUG ..... Going to award cargo -10 x 'Gold'
2007-03-13 23:29:45.411 Oolite[1981] DEBUG ::::: scriptAction: "awardCargo: -10 Platinum"
2007-03-13 23:29:45.411 Oolite[1981] DEBUG ::::: after expansion: "awardCargo: -10 Platinum"
2007-03-13 23:29:45.411 Oolite[1981] DEBUG ..... Going to award cargo -10 x 'Platinum'
2007-03-13 23:30:01.246 Oolite[1981] DEBUG ::::: scriptAction: "awardCargo: -10 Gem-Stones"
2007-03-13 23:30:01.246 Oolite[1981] DEBUG ::::: after expansion: "awardCargo: -10 Gem-Stones"
2007-03-13 23:30:01.246 Oolite[1981] DEBUG ..... Going to award cargo -10 x 'Gem-Stones'
2007-03-13 23:30:17.457 Oolite[1981] DEBUG ::::: scriptAction: "setMissionImage: none"
On the frontend it looks like the program has frozen completely. And it doesn't matter how big the amount is. "-1 Gold" takes the same time to add as "-1000 Gold".

And speaking of cargo-handling, I would very much like to have more influence on that in a script, apart from awardCargo, useSpecialCargo and removeAllCargo.

E.g. it would be nice to have methods to query the available cargospace of the player's ship and the amount of cargo currently taken. The latter one would be perfect if there would be not only a single counter for the cargospace used, but counters for every commodity.

So it could be cargospace_number, which returns an integer expressing the still available cargospace in tons,
cargo_number, which returns an integer expressing the filled cargospace in tons, and
food_number, textiles_number etc. up to gemStones_number and alienItems_number, integers expressing the current amount of all these items in their respective scale.

And as removeAllCargo doesn't remove Gold, Platinum or Gem Stones (they are kept in the safe in your cockpit, not in the cargo bay (BTW what kind of safe is that? I sometimes carry 150 kg of Gold and 1057 kg of Platinum with me--pretty spacious safe in my cockpit, it seems!)) a method like removeAllValuables would be nice, just to do the same to these.
Last edited by Commander McLane on Thu Mar 15, 2007 5:34 am, edited 1 time in total.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Well, having browsed the code, I think awardCargo: (please use the correct method name, makes it so much easer to find it…) handles negative values by not noticing. When you award a negative value, you actually award (4294967296 + intended_negative_quality) units, and the value wraps when it overflows or underfluws. This can be expected to take a while… although it still shouldn’t actually work.

I’m not going to fix this right now, but I’ll put it in the task tracker.

Edit: on further consideration, providing a more flexible read/write access to the cargo manifest via JavaScript is probably the way to go here, in addition to fixing awardCargo: to reject negative values.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

then still there would be a need for the negative method of awardCargo;
remove_cargo: <type> <number>.
disregarding negative results or setting them to zero should remove the need for a removeAllCargo: <type> method.
(4gems in hold, removeCargo: gems 6 = 0gems)
an oxp-er could just set removeCargo to a large number to get all removed.

---

I agree a method to determine cargoInHold would be nice for some trading-interactions.

What would be better a method that generates a numbers array of all cargotypes in hold or code that tracks what is in hold and saves this in queriable number_variables? (inHold_food_number)
Riding the Rocket!
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

I'd love to have the <name> string in shipInfos accept [descriptions].

---

Selectively overriding illegal_goods.plist in planet.plist or script.plist.

---

an effective way to "spawn: shiprole #" relative to an object-entity.
(dictated by spawn coordinates sceme in shipdata.plist)
location:
'shipcentric' X Y Z
facing direction:
like quaternion?
Riding the Rocket!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

@ Ahruman: Sorry for the mis-spelling :oops:. I've corrected it now.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

A shiplist key to switch roll to yaw.
(a replacement, not in addition)
For more ponderous hugeship movement.
Riding the Rocket!
Post Reply