IRC logs for #openttd on OFTC at 2018-09-01
⏴ go to previous day
01:27:42 <Samu> it got to look 2 tiles ahead
01:27:48 <Samu> to detect a possible bridge
02:05:16 *** Supercheese has joined #openttd
03:27:56 *** WWacko1976-work has joined #openttd
03:35:50 *** Supercheese has joined #openttd
05:46:50 *** haudrauf has joined #openttd
06:52:56 *** sim-al2 has joined #openttd
06:58:37 *** Alberth has joined #openttd
06:58:37 *** ChanServ sets mode: +o Alberth
07:51:30 *** Supercheese has joined #openttd
09:15:15 *** Progman has joined #openttd
09:55:19 *** sla_ro|master has joined #openttd
10:35:31 *** andythenorth has joined #openttd
10:38:13 *** HerzogDeXtEr has joined #openttd
10:41:35 *** Wacko1976 has joined #openttd
11:00:50 *** andythenorth has joined #openttd
11:34:57 *** Wormnest has joined #openttd
12:11:24 *** frosch123 has joined #openttd
12:42:53 <Samu> imagine I want to implement that for every road piece that is built
13:00:33 *** Stimrol has joined #openttd
13:11:03 <Wolf01> Pathfinder is ignoring my straight road and preferring the highway :S
13:12:30 <TrueBrain> your way of the highway
13:12:46 <Wolf01> I'll swap the entry and exit lanes, so they can't take the highway for 200m :>
13:14:01 <Alberth> Samu: what raising and lowering? I can only see two mostly identical blocks of code
13:14:33 <Samu> raising only the needed money for constructing the next thing, and then repaying it after
13:23:13 <Alberth> oh, only the airport type changes?
13:24:04 <Samu> no, I meant for every kind of things
13:24:30 <Samu> even demolishing stuff too
13:25:23 <Samu> refiting vehicles, everything that involves money
13:25:37 <Alberth> AIAirport.BuildAirport(airport1_location, airport1_type, airport1_stationId) <-- so this line changes every time
13:26:28 <Alberth> right, does squirrel have a function type as data?
13:27:29 <Samu> i guess it does, there's the Valuate functions
13:28:50 <Alberth> it exists according to the manual
13:29:25 <Alberth> "Functions are first class values like integer or strings and can be stored in table slots, local variables, arrays and passed as function parameters."
13:30:26 <Alberth> hmm, function parameters are known, or can they change each time?
13:31:41 <Samu> not sure I understand the question, but they can change, imagine a path of roads being built, the tiles always change
13:32:26 <Alberth> if they can change, make a base class that implements your test, except it calls a separate method to do the action
13:32:58 <Alberth> in a derived class, implement that separate method for the thing you want to test
13:33:13 <Alberth> in the derived class, you can also set parameters etc
13:33:35 <Samu> wow, too much lingo I don't fully get
13:33:53 <Samu> sounds like it's a difficult task for me
13:34:49 <Alberth> it's not that difficult, it just explodes a bit in size, as there are lots of things you can build
13:35:50 <Alberth> let's see how to do this, one moment
13:36:59 <Samu> woah, appreciate the time you take on helping me
13:45:17 <Alberth> Test class is the generic code, never changes. It calls "theaction()" to do the real test
13:45:58 <Alberth> TestBuildAirport class implements the "theaction" for building an airport, it tries, and simply returns the result
13:46:37 <Alberth> since it extends from Test, you can instantiate the TestBuildAirport class, and then call dotest() on it
13:46:58 <Alberth> code is fully untested :p
13:47:27 <Alberth> Test is the baseclass, and TestAirport is derived from it
13:47:48 <Alberth> "theaction" is the separate method I mentioned
13:48:19 <Alberth> I just copied some arbitrary lines from your paste, no idea if it is correct
13:53:21 <Wolf01> Mmmh, overcharged the UPS
13:54:11 <Wolf01> Let's try again if it's the video card
13:56:07 <Alberth> I hope the display is also behind the UPS, or you can't see a thing!
13:56:54 <Alberth> not to mention the router, or you'll have no network :)
13:56:56 <Wolf01> Everything is behind the UPS, that's why everything shut off when the UPS started screaming
13:57:21 <Samu> TestBuildAirport.dotest();
13:58:28 <Samu> never actually dealt with classes, so i'm getting some errors
13:59:48 <Alberth> first make an instance, you can't call the class directly
14:00:01 <Wolf01> I need to reinstall the powerchute
14:00:10 <Alberth> (or you can perhaps, but it doesn't do what you think it does)
14:01:35 <Alberth> local tap = TestAirport(loc, tp, id); tap.dotest();
14:02:39 <Samu> TAP is actually a portuguese air transport company
14:03:15 <Alberth> you can rename the variable, simpler than renaming the company :)
14:03:16 <Samu> or was... no longer portuguese, we sold it :8
14:04:14 <Samu> actually it's local tap = TestAirport(airport1_location, airport1_type, airport1_stationId);
14:04:20 <Alberth> everybody is at their desired location, no need for transport -> let's sell it :p
14:04:27 <Samu> loc, tp, id woudln't work
14:04:50 <Alberth> yeah, I don't know what values you have
14:05:06 <Samu> hmm the index TestAirport doesn't exist :(
14:06:11 <Samu> now I'm getting a weird error, never seen it before
14:07:58 <Alberth> "new slot operator not supported", which is the <- thing
14:08:50 <Samu> the index loc does not exist :(
14:09:27 <Samu> i need something before the constructor, isn't it?
14:09:35 <nielsm> maybe the field needs to be pre-declared
14:11:03 <Samu> the index HasMoney does not exist
14:11:18 <Samu> must be WrightAI.HasMoney?
14:12:23 <Samu> oh WrightAI.RepayLoan();
14:13:20 <Samu> the index last_cost does not exist, but that's already past the test, the airport was built :)
14:15:05 <Alberth> as for explosion in code size, you need a new derived class for each thing you test
14:16:28 <Alberth> and current code takes parameters values in the constructor, so you'd need a new instance for each test, which is very expensive. Better add a method to change the parameter values, and then call dotest()
14:24:27 *** Wacko1976 has joined #openttd
15:26:18 <Samu> can you explain me how do I do a method to change parameters stuff
15:28:02 <Samu> theaction is... modified?
15:30:53 <Wolf01> 3rd take on that game, I should save after doing things :P
15:46:31 <Samu> comparison between instance and 0
15:46:56 <Samu> uhm.. how do i get the result of the test for comparison?
15:48:17 <Samu> local tap = TestBuildAirport(airport1_location, airport1_type, airport1_stationId); tap.DoBuildAirport(); if (tap < 0) {
15:48:28 <Samu> can't compare tap and 0 halp!
16:00:09 <Samu> it's always returning a false?
16:02:11 <Alberth> tap is an object, likely tap.DoBuildAirport() returns the result of the test?
16:03:13 <Alberth> ie "calling" the class makes an object, an instance of the class
16:04:00 <Alberth> on that object you can get its values and call its methods (=functions of the object)
16:05:25 <Alberth> alternatively, you store the answer in the object, and then retrieve it using the tap variable
16:06:12 <Samu> i was hoping for a 0 or a -1
16:06:20 <Samu> these were the values I was expecting
16:06:38 <Alberth> what does DoAirport() look like?
16:06:57 <Alberth> or perhaps just the entire class :)
16:08:26 <Samu> i changed -1 to false and true to 0, i was testing some stuff
16:08:34 <Samu> eventually they should be -1 and 0 respectively
16:09:10 <Alberth> you shouldn't call DoBuildAirport , unless you want to just build an airport without your test
16:09:53 <Alberth> tap.DoMoneyTest() should give you true or false
16:10:49 <Alberth> or add one more layer, to set the parameters as well, let me show that
16:33:24 <Samu> tap = TestBuildAirport(); if (!tap.TryBuild(airport2_location, airport2_type, airport2_stationId)) {
16:33:56 <Samu> waiting for a case where it can't build
16:42:26 *** chomwitt has joined #openttd
16:48:45 <Samu> gonna try do for a build engine
17:07:18 <Samu> hmm harder to do for vehicle
17:07:30 <Samu> it got to return the vehicle in this case
17:08:42 <Samu> it didn't simplify that much for the vehicle case, I must have failed
17:14:14 <Alberth> In DoBuildVehicle() store the vehicle in a variable of the class, and return success / failure, so your test-code knows what to do
17:14:59 <Alberth> then in TryBuild, call the baseclass method, and if it returns success, return the vehicle else null
17:16:00 <Alberth> you didn't need a price before? with the airport?
17:16:32 <Samu> yes, but it was all dealt with inside that test
17:17:01 <Samu> didn't need it outside that part
17:17:28 <Alberth> make a new method in the derived class like GetPrice() or so, which you call from the baseclass money test
17:17:54 <Alberth> so you can change GetPrice() each time without modifying the money test
17:49:04 <Samu> seems to work, but i don't think that's what you wanted
17:52:44 <Alberth> seems much like I want
17:54:11 <Samu> the MoneyTest class is the one that must fit all my cases?
17:54:15 <Alberth> I don't understand your reason for the money test though :)
17:54:43 <Alberth> as much as possible, as it reduces the amount of code that you have to write
17:54:57 <Alberth> that's what we started with right? :)
17:55:45 <Samu> in the buildvehicle case I actually needed to get the vehicle, to do stuff with it
17:55:53 <Samu> it was a bit more complicated
17:56:13 <Samu> in the build bridge, build road, i expect not needing anything
17:57:14 <Samu> strange, that means the airport implementation is wrong
17:57:39 <Alberth> build truck would also give a vehicle, doesn't it?
17:58:01 <Alberth> the difference is that you don't want to do anything with a bridge
17:58:18 <Alberth> while you want to give orders etc to a vehicle
17:59:09 <Alberth> you could of course walk through all vehicles to find the one without orders
17:59:30 <Alberth> probably like you walk through all your stations to find new oppportunities
18:00:17 <Samu> gonna rework the airport again, brb
18:06:01 *** Arveen2 has joined #openttd
18:08:39 <Samu> instead of DoBuildAirport, DoBuildVehicle, I actually give it a common name
18:09:44 <Samu> assert(AIError.GetLastError() != AIError.ERR_STATION_TOO_SPREAD_OUT);
18:09:48 <Samu> hmm, i actually need this
18:19:15 <Samu> i don't need a p = null; after all
18:19:29 *** Gustavo6046 has joined #openttd
18:22:27 <Samu> class TestBuildVehicle extends MoneyTest {
18:22:35 <Samu> class TestBuildAirport extends MoneyTest {
18:22:45 <Samu> now they both extends the same class
18:24:01 <Samu> hmm nop, it's failing to build airports
18:27:38 <Samu> AITestMode() && AIAirport.BuildAirport(loc, tp, id);
18:28:06 <Samu> not inside any if or local
18:30:27 <Samu> i have the master class MoneyTest that suits 2 different build methods
18:30:34 <Samu> build vehicle and build airport
18:30:57 <Samu> I'm wondering if line 27 is valid
18:31:44 <Samu> in the game I see it building airports and aircraft, so it seems fine, but code-wise... seems weird
18:35:18 <Alberth> inside a GetPrice function?
18:35:55 <Alberth> it computes the truth value of the expression, and then discards the result
18:36:32 <Alberth> weird place to build an airport :p
18:38:09 *** DorpsGek_II has joined #openttd
18:38:09 <DorpsGek_II> [OpenTTD/DorpsGek-github] TrueBrain pushed 1 commits to pyup-scheduled-update-2018-09-01:
18:38:09 <DorpsGek_II> - Update aiohttp from 3.3.2 to 3.4.1 (by pyup-bot)
18:38:18 <DorpsGek_II> [OpenTTD/DorpsGek-github] TrueBrain pushed 1 commits to pyup-scheduled-update-2018-09-01:
18:38:19 <DorpsGek_II> - Update attrs from 18.1.0 to 18.2.0 (by pyup-bot)
18:38:27 <DorpsGek_II> [OpenTTD/DorpsGek-github] TrueBrain pushed 1 commits to pyup-scheduled-update-2018-09-01:
18:38:28 <DorpsGek_II> - Update cryptography from 2.3 to 2.3.1 (by pyup-bot)
18:39:03 <Alberth> if (AITestMode()) AIAirport.BuildAirport(loc, tp, id); is likely easier to read
18:39:06 <DorpsGek_II> [OpenTTD/DorpsGek-runner] TrueBrain pushed 1 commits to pyup-scheduled-update-2018-09-01:
18:39:06 <DorpsGek_II> - Update aiohttp from 3.3.2 to 3.4.1 (by pyup-bot)
18:39:12 <DorpsGek_II> [OpenTTD/DorpsGek-runner] TrueBrain pushed 1 commits to pyup-scheduled-update-2018-09-01:
18:39:13 <DorpsGek_II> - Update attrs from 18.1.0 to 18.2.0 (by pyup-bot)
18:43:39 <Samu> local vehicle = TestBuildAircraft.TryBuild(best_hangar, engine);
18:44:49 <Samu> my buildairport function is a complete mess
18:45:06 <Samu> i'm surprised everything works
18:45:55 *** Gustavo6056 has joined #openttd
18:47:25 <Samu> i'm so scared of showing this to someone lol
18:48:25 <Samu> for a single function :(
18:50:33 *** Gustavo6056 is now known as Gustavo6046
19:09:25 <Alberth> lot of commented code, which you can all remove
19:10:39 <Alberth> wouldn't it be simpler to add only airports that you can actually use?
19:11:24 <Alberth> 18-20 adds 3 heli stations, which you may remove after line 67
19:11:37 <Alberth> why not move line 67 before line 18?
19:13:59 <Alberth> make a function that takes an airport type, and adds it to the list only if all the conditions at lines 24-38 hold
19:14:26 <Alberth> 11-20 then simply call that function
19:24:32 <Samu> I needed all airport types the game can offer in 1 single place
19:29:16 <Samu> ah, instead of filtering out from a list, I would add up to the list
19:29:34 <Samu> the opposite of what I did
19:31:15 <Samu> but i still need a list of all airport types available anyway
19:31:59 <Samu> i couldn't use that for cycle
19:33:03 <Samu> ah, maybe it's doable, without a for cycling through
19:33:45 *** haudrauf has joined #openttd
19:35:14 *** Wacko1976 has joined #openttd
19:43:39 <Alberth> you have a sequence to add all types now too
19:43:55 <Alberth> so have a sequence of testing + adding instead
19:46:10 <Samu> test for engines available
19:46:29 <Samu> if true, add corresponding airport type and only if it's available
19:46:40 <Samu> and what about heliport removal for 2nd airport
19:47:28 <Samu> hmm I think I prefer the way I have it for the moment
19:48:19 <Samu> I can't think I could build up a list
19:49:42 <Samu> if I add it in duplicate, i would get it listed twice?
19:49:56 <Samu> if I remove it in duplicate, I don't have that issue
19:51:06 <Samu> and the prices always change, I always have to keep the costs
19:51:12 <Samu> especially with inflation
19:51:37 <Samu> i can't think of doing the list in build-up way
19:59:31 *** Gustavo6056 has joined #openttd
20:01:56 *** Supercheese has joined #openttd
20:05:23 *** Gustavo6056 is now known as Gustavo6046
20:06:31 *** tokai|noir has joined #openttd
20:06:31 *** ChanServ sets mode: +v tokai|noir
20:10:41 *** Stimrol has joined #openttd
20:20:49 *** agentw4b has joined #openttd
20:24:59 *** Wacko1976 has joined #openttd
21:00:45 *** gelignite has joined #openttd
21:10:34 *** Stimrol_ has joined #openttd
21:21:55 *** Supercheese has joined #openttd
21:30:33 *** Stimrol has joined #openttd
21:51:57 *** Progman has joined #openttd
22:26:46 *** sim-al2 has joined #openttd
23:12:17 <Samu> I have class MoneyTest inside Utils.nut file
23:12:51 <Samu> WrightAI.nut can call it without a require("Utils.nut");
23:13:16 <Samu> why does it require a require("Utils.nut");
23:14:32 <Samu> well, i'm clueless about such a chain, this code wasn't originally mine
23:15:16 <Wolf01> Do you have other includes in wrightai which may include utils.nut?
23:16:07 <Samu> class WrightAI extends AIController {
23:16:22 <Samu> function WrightAI::UpdateAircraftLists() {
23:16:32 <Samu> all functions have WrightAI::
23:16:47 <Samu> then i also have some classes
23:16:50 <Samu> class TestRefitAircraft extends MoneyTest {
23:17:32 <Wolf01> Did you at least try to parse what I asked you?
23:17:58 *** Gustavo6056 has joined #openttd
23:19:26 <Samu> there are a lot of requires in main.nut
23:19:35 <Samu> including require("Utils.nut");
23:19:43 <Samu> require("WrightAI.nut");
23:19:51 <Samu> require("BuildManager.nut");
23:20:51 <Samu> but apparently, I'm getting MoneyTest does not exist, or invalid, sec let me get correct error
23:21:00 <Samu> when i do it inside buildmanager
23:22:42 <Samu> line 40 is this: class TestRemoveRoadStation extends MoneyTest {
23:22:59 *** Gustavo6056 is now known as Gustavo6046
23:23:10 <Samu> MoneyTest is a Class inside Utils.nut file
continue to next day ⏵