[Mod] UT CaC v0.20 ( Old Name: Not Another Trader ) - Architect integrated

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

ok, finally at home so i can answer you properly :)

1. Yes, want to do something for all Employee types in the long run, but in the forseeable future i wont need another Button. Maybe when i introduce Station-Independent Fleets and Trading but i dont have a clear plan yet when i will start working on this (this Part would need one on the Captain, and the Manager one may also be used in any situation at some point, not only when assigned to a Station)

2. partially, yes.. thinking about renaming this Var to $actor.$ut_cac at some point because i stuffed in all kinds of Data about my Script in there not just settings.. so just check for both just in case ;) will remove them of course if i introduce Back-Conversions to Vanilla behavoir.
Will add your $actor.$InUse == true Var in the next Version, no problem ;)

3. This is mostly because i knew in advance that i will need many functions and it would quickly get difficult to organise everyhing in a consistent manner - so i decided to rewrite the Dialogue tree from Scratch, too and share as much as possible between all Actors to make them completely consistent (ok, only within my Script maybe, but if i ever finish this i will also make my dialogue Tree the default one - may take one or two years till that though i think)

4. Yep i am looking into this, but i stil dont understand how Parameters are passed from MD to lua - i can see where they are acessed in the lua script but i have no idea how the Vars get their Value.. already found out how i could modify the conversation flow, but without passing the Action and next (sub)sections there is no use to this
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

It's pretty straightforward. Take an example from YAT v2 :

Code: Select all

          <open_conversation_menu menu="YATConfigureMenu" param="[0, 0, $oThisShip]" />
          <add_conversation_view view="closeupdetailmonitor" />
where the file YAT_menu_configure.lua has the menu definition

Code: Select all

local menu = {
	name = "YATConfigureMenu",
	white = { r = 255, g = 255, b = 255, a = 100 },
	red = { r = 255, g = 0, b = 0, a = 100 },
	transparent = { r = 0, g = 0, b = 0, a = 0 }
}
param is a list (which can contain other lists as members). The first 2 entries are both 0 which appears to be required but I do not know why - perhaps a ui dev can chip in for this.

lua then reads the $oThisShip value as menu.ship = menu.param[3]

when we are ready to return some data we can use this sort of code to pass a param (list) back to an xml section handler :

Code: Select all

elseif rowdata == "home_zone" then
				Helper.closeMenuForSubSection(menu, false, "gMainNav_menumap", {0, 0, "selectzone", menu.pilotsector, nil, menu.pilotzone, {"gYAT_SetHomeZone"} })
				menu.cleanup()
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

YorrickVander wrote:lua then reads the $oThisShip value as menu.ship = menu.param[3]
this is excactly the point which i cannt find - where does it say that the menu.param[3] should also be called menu.ship and not menu.action for example
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

In the onShowMenu function. Tip, if you want dummy lua you can still use this then exit again before drawing anything :)

Code: Select all

function menu.onShowMenu()
	menu.title = ReadText(98981, 14)
	menu.ship = menu.param[3]
	menu.pilot, menu.pilotsector, menu.pilotzone = GetComponentData(menu.ship, "pilot", "sectorid", "zoneid")
	menu.pilotmoney = GetAccountData(menu.pilot, "money")
	if menu.pilotmoney == nil then
		menu.pilotmoney = 0
	end
	
	menu.task = GetNPCBlackboard(menu.pilot, "$task")
	menu.maxbudget = GetNPCBlackboard(menu.pilot, "$maxbudget")
	menu.homezone = GetNPCBlackboard(menu.pilot, "$homezone")
	if menu.homezone == nil then
		menu.homezone = menu.pilotzone
	end
	
	menu.displayMenu()
end
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

ah, thanks :) still have to get used to lua - i am used to the assumption that all starting Values/Parameters are found relatively in the beginning of the File, not somewhere in the middle.. makes it easier to follow the Program Flow in the head imo

think this makes removing the aforementoined workaround a feature i can promise for the next Version :)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp »

Hi Uni,

On the off chance yourself or other modders have not seen some of the recent changes and additions to the modding guides on the wiki, including to the Lua one (although not since September), I made a note about them here.

Regards,
Sparks
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

UniTrader wrote:i am used to the assumption that all starting Values/Parameters are found relatively in the beginning of the File, not somewhere in the middle.. makes it easier to follow the Program Flow in the head imo
Not really much different to most languages where function and class definitions precede the entry point. I'll look forward to seeing your results :)
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz »

UniTrader wrote:1. Yes, want to do something for all Employee types in the long run, but in the forseeable future i wont need another Button.
Good to know, thanks. HR's "Convert Employee..." compatibility buttons wil def be going somewhere in Manage Employee then, since that will maintain the best menu continuity among all actor types and contextual frames where the conversion can be done without breaking something else.



Some more notes on passing data to/from LUA menus, in addition to what Yorrick said --

- consider <open_conversation_menu menu="Whatever_Menu" param="event.param2" param2="event.param3"/>

- "event.param2" is generally used to pass data forwards through the section structure while "event.param3" is often used to pass data backwards.

- The param2 definition in this case may be expecting to get data back along the "event.param3" channel from a slider submenu or something -- slider submenus close via section returns rather than section calls -- while param is expecting it's data from the initial menu call along the "event.param2" channel.

- when you then get into Whatever_Menu's menu.onShowMenu function, menu.param will reference "event.param2" and menu.param2 will reference "event.param3" -- and menu.param[3] will reference "event.param2.{3}" and menu.param2[5] will reference "event.param3.{5}" and so on.
I3laze
Posts: 78
Joined: Tue, 13. Oct 15, 11:52
x4

Post by I3laze »

Hi UniTrader, I have read through the 6 pages but I'm unsure if the station traders will trade galaxy wide or not with your mod?

I've had a little mess around with the range settings from a station in Devries and reset slot 1 to system Omricon. Does that mean it will only trade in Omircon to my station? Also I don't understand what the jump setting and highway setting (I think that is what they are, sorry at work atm) are for?

Will your mod have a option for supplying player to player staions? I'm sure it was something you could do in the x3 games, not sure if it was a mod or vanilla thing. Also blacklisting wares not to sell or buy maybe?

Anyway great mod and look forward to final release.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

in theory my Manager can cover 2 Clusters plus 3 Sectors with a Manager who has 5 Stars in Navigation (see this Manual Page, but planning on changing this relatively static limits to a more dynamic point-based system (not with the next Version though, will focus on minor usability improvements there)

Also not planning on implementing something like a Logistics part for now, but the next Version will contain an Option to restrict all Trading to be done with Player stations only. Limited Blacklisting is also basically implemented in the form of the restriction to legal, licenseable, licensed or all Wares although i forgot to add an Option to modify this behavior (will be part of the next Version)

Also there will probably be no final Release because i have plans for this in all possible and some impossible directions :D
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
I3laze
Posts: 78
Joined: Tue, 13. Oct 15, 11:52
x4

Post by I3laze »

UniTrader wrote:in theory my Manager can cover 2 Clusters plus 3 Sectors with a Manager who has 5 Stars in Navigation
So If I'm correct with a 5 star manager I can set slot 1 for cluster/sector Omricon and it will trade in only 3 of the 4 sectors from the main jump gate in Omricon? If I also want the station to trade in it's home system Devries do I have to add that cluster to slot 2?

Thanks for your help btw
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

If your Station is in Glaring Truth you should set these as Ranges:
1. Glaring Truth
2. Molten Archon
3. Omicron Lyrae

make sure all Areas where you want to Trade or Mine are highlighted blue in the end by activating Jump Range on them (or green, but this is only possible for GT itself because when using Higways you have to pass Barren Heart on the Way back which is not in the List, so highway range is automatically deactivated for them)

If you left out the Home Space of the Station (can be Zone or Sector or Cluster) it wont work because the useable Range must be continonous. i do not enforce setting a Stations Home Space as Range Setting yet, but it wont work if it isnt done because there is always a part of the Path not in the List. Either thinking about adding this requirement or removing the continuty requirement under certain conditions, not sure yet...

also Range Setting Omicron includes all of Omicron for Trading and Mining, not just a selection of its Sectors.

you can of course also set DV and OL as Range but this Setting allows Mining Ships to Work in Barren Heart and also allows Small Ships to fly through there which is Reiver Space and i think you want to avoid that..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
I3laze
Posts: 78
Joined: Tue, 13. Oct 15, 11:52
x4

Post by I3laze »

Ok I get it now, So if I wanted to trade in Albion then the list would be as follows:

1. Glaring Truth
2. Molten Archon
3. Bleak Pebble
4. Albion

This way I am black listing Barren Heart on my way to Albion?

Again thank you for helping me, It's slowly sinking in for me :wink:
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

not yet, dont have clever Pathing based on the whitelist yet.. for Jump and Highway Range i am just confirming that the Path from and to the Destination Range is completely inside the current Set of Ranges/whitelisted so Paths will not lie outside there.. interesting idea, already considered implementing it - but i have other priorities with this currently.. and when these are done you probably dont have to worry about minor threats on the way ;)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
I3laze
Posts: 78
Joined: Tue, 13. Oct 15, 11:52
x4

Post by I3laze »

Hi, me again :roll:

Ok I've got your mod running on my food complex and have set up the ranges, gave the manager a Titurel and a Rahanas Container. They both went off and brought fuel cells and delivered back to the station, ok so far. The Titurel then loaded space fuel and transferred it to my cell fab. It then returned and did the same but this time transferred to my construction shop.

Does the manager look at supplying my own stations first before trading for a profit? I like this feature but space fuel is a secondary resource and I could be making proffittssss from it.

Also why does the manager only tell my Rahanas to only buy fuel cells and not purchase or sell resources. Does it only work for XL freighters. My station has plenty of food rations to sell and there is demand for it. I do have a heavily modded game so that may not help if L frieghters are supposed to work.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

finally at home where i can properly type :)

Explaination how the Manager searches for Trades, which basically happens in two Steps:

1. Create Ware Priority List
basically Ware Priority is empty percentage (for ressources) or fill percentage (for products) of Wanted amount (there is a multiplier for secondaries of 0.75 for this and a multi of 0.5 for tradewares so they are considered less important than primaries) and the Wares in this List are ordered by it
1.1 if current Ship is equipped for mining and a mineable Ressource has priority of 1.0 -> send it mining immediately

2. Iterate through this List to find fitting Trade Offer
For each Ware the Manager loops through all Ranges in order and send the Ship for the first Trade which fits the criteria:
=> better Price than current Station offers (or default Price as fallback in case there is currently no Offer)
=> at least 10% of the Ships Cargo Space is used during the Trade
=> Only Trade offers known to the Player are considered (this differs from Vanilla behavior which magically knows all possible Trades - and i think you know too few Deals so the Manager also doesnt know about that many - therefore he does what he can)

Also note that when a Ship executes a Trade the Offers of the Tradingpartner are updated for the Player (same as vanilla, but probably unknown to many that this happens)

regarding the Ships: i only tested with big Trading Ships so far (Scaldis and Lyranea), but if any Trade with small Ships works (and getting Fuel is one of those) all should work (small Ships use the vanilla scripts for navigation and docking atm, so i doubt it fails there)


Also could it be that your Ships were not empty when assigning them? i have a routine which just empties Cargo anywhere in case the Cargo bay is more than half full to prevent Lockups, next Version will include a priority to unload these Wares on the Commander Station though

i could exactly tell you what happens if you create a Logfile, activate the Log output on the Manager (talk to him => 6 - 3 ) and send me the related Logfile. dont forget to deactivate this when done though (select the same option again), because it is relatively verbose and can make the debulog unuseable for locating other bugs.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp »

How firm is the 10% of cargo rule? It could cause issues in bigger ships with the higher-end, rarer items items like RMP and FRs. For example, they would be 1000 and 263 units for a 200,000 m3 cargo (greater numbers of units than batch sizes).
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

its not written in stone, just want to prevent the manager to buy energy cells for less than the jumpcost to the destination Sector with that.
and yeah, you are right, didnt think about this kind of products.. but just looked up the Data for RMP: each batch are 100 Units (default method) with a Volume of 20m³ per unit, so for this Ware the minimum considered for buying would be a full batch, which has a total volume of 2000m³. Also opposed to Vanilla Station Trading i am doing aggressive Reservations, so when the Manager decided for a deal it is reserved immediately which

but yeah, other limits may be better.. maybe use the total Price as limitation? (total Price of Traded Ware is at least the same as the Jumpcost, or for small ships 10% of the value of the Ship)

EDIT: corrected sentence
Last edited by UniTrader on Wed, 14. Oct 15, 21:48, edited 1 time in total.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
I3laze
Posts: 78
Joined: Tue, 13. Oct 15, 11:52
x4

Post by I3laze »

I fired up the game tonight and the Rahanas are trading like the XL freighters now. I just need to see them buying resources and then you have made me a happy man.

I look forward to the coming updates.
Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp »

Hmm, good point. I was just thinking about efficiency as a rationale.

Would it be possible to subtract an estimate of fuel cost from the profit equation (maybe using the station's existing fuel buy price if possible)?

As an aside, might an up-weighing when selling for stations with max buy %s be useful? A sort of economy-helper function where kick-starting a stalled production line with 'lower profit product B' could be favoured over selling 'high profit product A' when both are made at same station.

Return to “X Rebirth - Scripts and Modding”