<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AChangeTrade</id>
	<title>API:ChangeTrade - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AChangeTrade"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:ChangeTrade&amp;action=history"/>
	<updated>2026-10-18T04:54:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:ChangeTrade&amp;diff=30215&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:ChangeTrade&amp;diff=30215&amp;oldid=prev"/>
		<updated>2026-10-16T19:41:04Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Trade}}&lt;br /&gt;
Changes the player&amp;#039;s side of the current trade (items or money) and sends the update to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ChangeTrade(tradeSlot, inventorySlot, backpackType, money)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;tradeSlot : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – What to change. &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; updates the money offer only. &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;–&amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt; adds or removes an item (see Details).&lt;br /&gt;
;inventorySlot : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Slot of the item to add, inside its backpack. &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; removes the item in trade slot &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
;backpackType : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Backpack that &amp;lt;code&amp;gt;inventorySlot&amp;lt;/code&amp;gt; belongs to (the &amp;lt;code&amp;gt;EA_Window_Backpack.TYPE_*&amp;lt;/code&amp;gt; values: 1 quest, 2 inventory, 3 currency, 4 crafting).&lt;br /&gt;
;money : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Money offered. Only read when &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* The client keeps a list of the items the player offers (up to 9) and the money amount. After changing that list it sends a trade update with the full list and money to the current trade partner.&lt;br /&gt;
* &amp;lt;code&amp;gt;tradeSlot = 0&amp;lt;/code&amp;gt;: stores &amp;lt;code&amp;gt;money&amp;lt;/code&amp;gt; as the money offer and sends the update. The item list is unchanged.&lt;br /&gt;
* &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; 1–9 and &amp;lt;code&amp;gt;inventorySlot = 0&amp;lt;/code&amp;gt;: removes the item in that trade slot. Later items move up one slot.&lt;br /&gt;
* &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; 1–9 and &amp;lt;code&amp;gt;inventorySlot&amp;lt;/code&amp;gt; not 0: appends the item to the end of the list. The actual value of &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; does not matter here; the stock UI always passes &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;inventorySlot&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;backpackType&amp;lt;/code&amp;gt; are turned into the item&amp;#039;s absolute inventory slot before it is stored.&lt;br /&gt;
* Any other &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; value sends the update without changing anything.&lt;br /&gt;
* The money value is only stored when &amp;lt;code&amp;gt;tradeSlot&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;; in the other cases the last stored amount is sent again.&lt;br /&gt;
* The stock UI calls &amp;lt;code&amp;gt;ChangeTrade(0, 0, 0, money)&amp;lt;/code&amp;gt; to take back an acceptance (&amp;lt;code&amp;gt;EA_Window_Trade.UnacceptTrade&amp;lt;/code&amp;gt;).&lt;br /&gt;
* The client does not check for duplicate items or for more than 9 items, and removing an empty trade slot still shortens the list by one. Keep track of the offer in Lua, as the stock trade window does.&lt;br /&gt;
* Does nothing if the player object does not exist yet.&lt;br /&gt;
* The function needs at least four arguments and only reads the last four. All must be numbers.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
None besides the generic &amp;#039;&amp;#039;Invalid Parameters&amp;#039;&amp;#039; message when an argument is not a number.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
From &amp;lt;code&amp;gt;default/ea_tradewindow/source/tradewindow.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- which trade slot we&amp;#039;re requesting doesn&amp;#039;t matter so just hardcoding 1,&lt;br /&gt;
--   since server is just putting it in first available slot&lt;br /&gt;
ChangeTrade( 1, invSlotNum, backpackType, EA_Window_Trade.myOfferMoney )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- tell server we&amp;#039;re removing item from trade&lt;br /&gt;
ChangeTrade( slot, 0, 0, EA_Window_Trade.myOfferMoney )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:InitiateTrade|InitiateTrade]]&lt;br /&gt;
* [[API:AcceptTrade|AcceptTrade]]&lt;br /&gt;
* [[API:CancelTrade|CancelTrade]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>