{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreidv4y4otjwkef7j3qo35sma4dljmbycq2bzvrqhxverhzxihbtfja",
"uri": "at://did:plc:i7budt2wflrcfy6jtvfocbix/app.bsky.feed.post/3mg2q4x75xy32"
},
"path": "/viewtopic.php?p=1278347#p1278347",
"publishedAt": "2026-03-02T05:20:02.000Z",
"site": "https://www.tt-forums.net",
"tags": [
"HERE",
"GoldMine"
],
"textContent": "I did a little test as follows and it appears copying an AIList is not by reference as documented, but by value:\n\n\nCode:\n\n\n function TestList() {local lst = AIList();lst.AddItem(0, 0);lst.AddItem(1, 1);lst.AddItem(2, 2);lst.AddItem(3, 3);lst.AddItem(4, 4);lst.AddItem(5, 5);lst.AddItem(6, 6);lst.AddItem(7, 7);local copy = AIList();copy.AddList(lst);lst.RemoveItem(0);Log.Info(lst.HasItem(0), lst.Count());foreach(item, v in lst) {Log.Info(item, v);}Log.Info(copy.HasItem(0), copy.Count());foreach(item, v in copy) {Log.Info(item, v);}}\n\nAttached image is the result:\n\n\nAs you can see, the original list \"lst\" had item 0 removed, but the copy kept the item, however the docs HERE say this:\n\n> Postcondition\n> The list to be added ('list') stays unmodified.\n\nSo what is going on?\n\nIsn't copy by reference? if it is then how is it possible that the item being removed stayed in copy, it should have been removed right?\n\nIs this just coincidence I shouldn't rely on?\nPlease enlighten me.\n\nStatistics: Posted by GoldMine — 02 Mar 2026 05:20\n\n* * *",
"title": "OpenTTD AIs and Game Scripts • Re: nasal demons in action",
"updatedAt": "2026-03-02T05:20:02.000Z"
}