Trading Ship Problem

Freeform discussion about anything related to modding Transcendence.
Post Reply
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

http://xelerus.de/index.php?s=mod&id=95

This mod is in development, but you shouldn't encounter many crashes if you try to run it.

Look for the DrakeMerchant ship, it sucessfully sells stuff. You should know that it has an event that causes it to dissapear once the player moves too far away from it though.


I created this ship with help from the code of a "Salvager Nomad Store" (or something like that) mod.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

The code in this part of the ship probably overrides that.

Code: Select all

<Action name="Buy items" imageID="&rsItemListScreen;" imageIndex="1" default="1" key="B">
(block Nil
;some code
)
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I am not sure that's the issue, because if gMargin is Nil then the dsExchangeBuy looks for the trade tag in a station.

The trade tags are for Stations, and Ships vs. Stations as game objects are treated differently, some things that work in stations won't work in ships.

So, you might actually need to create the gMargin defined for trade somewhere else.

To do that you can make a custom function much like the (setq gMargin (intTeratonBuyMargin)) is done for the Teratons to have their special margins set.
Last edited by Periculi on Thu May 15, 2008 12:52 am, edited 1 time in total.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

I believe my example changes gMargin (and I think that was necessary)
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I don't understand.
Are you talking about what you posted there?
You must realize that this-

Code: Select all

<Action name="Buy items" imageID="&rsItemListScreen;" imageIndex="1" default="1" key="B">
(block Nil
;some code
) 
-won't work because you haven't even defined what the action should be. The action is meant to be: Go to the Buy Items screen.

How does ';some code' accomplish this?

You must define the screen to go to in that block with (scrShowScreen [screen pointer]) and to even use the dsExchangeBuy you must define a previous screen or prev screen & prev pane to return to. If it's not defined, you won't be able to exit the ExchangeBuy back to the Trade ship screens.

An undefined gMargin is exactly the same as gMargin Nil. So, again in the dockscreen ExchangeBuy you run into the need for the trade tag to be defined, and I still don't think it will work on a ship like it does on a station.

Let's look at what dsExchangeBuy expects:

Code: Select all

<!-- Commodities Exchange
	
	gPrevScreen: Must be set to the name/UNID of the screen to
			navigate to when done.
	gMargin: This is the mark-up as a percentage of the item price.
	gShowCriteria: Only shows items that match this criteria ('*' = all items)

	-->
Ok, now at the top of dsExchangeBuy you see this:

Code: Select all

<ListOptions
			dataFrom=	"station"
			list=		"*"
			>
		(switch
			(not gMargin)
				(scrSetListFilter gScreen intComputeSellPrice)
				
			(isfunction gMargin)
				(scrSetListFilter gScreen gMargin)
				
			(scrSetListFilter gScreen gShowCriteria)	
			)
	</ListOptions>
(not gMargin) is important to us in this discussion because we have either gMargin Nil or no gMargin at all. In that case, the switch in the list calls for the function intComputeSellPrice. Let's look at that function:

Code: Select all

		(setq intComputeSellPrice (lambda (thisItem)
			(objGetSellPrice gSource thisItem)
			))
So, if gMargin is not set, we get the item's own value according to gSource

How does a station set the trade adjustment?

A little lower down in dsExchangeBuy we find:

Code: Select all

(switch
								; If gMargin is Nil then we ask the station for the
								; price of this item.
								
								(not gMargin)
									(setq gCost (objGetSellPrice gSource thisItem))
"If gMargin is Nil the we ask the station for the price of this item."

And this is why I think that a Ship and a Station are being treated differently. Because if the trade tag in the ship was being processed correctly we wouldn't be having this discussion. It should have adjusted the prices for the Trade Ship, but because it didn't I think that:
A) Trade Tags don't function for ships, and
B) you must set gMargin with a function to get around it.

Is that making any sense?

In the Drake Merchant ship, the gMargin is set to a static amount, and therefore does work fine. However, it makes no difference between types of items. This works, if you want a straight percent adjustment.

If you wanted to recreate the trade tag what we could do is use a function like the Teratons to set gMargin. Something like (setq gMargin tradeShipMarginBuy) which goes to a little global function that creates the same price adjustments as the <Trade> tag should be doing.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

Periculi wrote:I don't understand.
Are you talking about what you posted there?
You must realize that this-

Code: Select all

<Action name="Buy items" imageID="&rsItemListScreen;" imageIndex="1" default="1" key="B">
(block Nil
;some code
) 
-won't work because you haven't even defined what the action should be. The action is meant to be: Go to the Buy Items screen.
That was merely to show where to look for the problem, not to provide an example.

your explanation is reasonable for why setting gMargin was necessary in my Drake Merchant ship, and confirms that setting gMargin overrides anything in the <trade> tag. That was all I was saying anyways.

It is possible to emulate a trade tag using a function. You can look for an example in Teraton.xml (look at the end of the file).
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

:oops: oh.. Sorry F50, I thought you meant that posted bit.

Back on the ships vs. station issue- I really do think that is the problem as to why the trade tag won't alter the prices for the trade ship. I suppose I should do a test, but I am stuck trying to get this loop to work for tracing the star network in Sys26.. and it's a real problem to figure out.
Post Reply