Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
/* Utils.nut */ function Utils::HasMoney(money) { local loan_amount = AICompany.GetLoanAmount(); local max_loan_amount = AICompany.GetMaxLoanAmount(); local bank_balance = AICompany.GetBankBalance(AICompany.COMPANY_SELF); if (bank_balance + max_loan_amount - loan_amount >= money) return true; return false; } function Utils::GetMoney(money) { local bank_balance = AICompany.GetBankBalance(AICompany.COMPANY_SELF); if (bank_balance >= money) return; local request_loan = money - bank_balance; local loan_interval = AICompany.GetLoanInterval(); local over_interval = request_loan % loan_interval; request_loan += loan_interval - over_interval; local loan_amount = AICompany.GetLoanAmount(); local max_loan_amount = AICompany.GetMaxLoanAmount(); if (loan_amount + request_loan > max_loan_amount) { AICompany.SetLoanAmount(max_loan_amount); } else { AICompany.SetLoanAmount(loan_amount + request_loan); } } function Utils::RepayLoan() { local bank_balance = AICompany.GetBankBalance(AICompany.COMPANY_SELF); local loan_amount = AICompany.GetLoanAmount(); local repay_loan = loan_amount - bank_balance > 0 ? loan_amount - bank_balance : 0; AICompany.SetMinimumLoanAmount(repay_loan); } class MoneyTest { function DoMoneyTest() { local price = GetPrice(); if (Utils.HasMoney(price)) { Utils.GetMoney(price); } if (DoAction()) { Utils.RepayLoan(); return true; } Utils.RepayLoan(); return false; } } /* WrightAI.nut */ class TestBuildAirport extends MoneyTest { l = null; t = null; i = null; function DoAction() { return AIExecMode() && AIAirport.BuildAirport(l, t, i); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIAirport.BuildAirport(l, t, i); return cost.GetCosts(); } function TryBuild(airport_location, airport_type, airport_stationId) { l = airport_location; t = airport_type; i = airport_stationId; if (DoMoneyTest()) { return true; } assert(AIError.GetLastError() != AIError.ERR_STATION_TOO_SPREAD_OUT); return false; } } class TestBuildAircraft extends MoneyTest { h = null; e = null; v = null; function DoAction() { v = AIVehicle.BuildVehicle(h, e); if (!AIVehicle.IsValidVehicle(v)) { return false; } return true; } function GetPrice() { return AIEngine.GetPrice(e); } function TryBuild(best_hangar, engine) { h = best_hangar; e = engine; if (DoMoneyTest()) { return v; } return null; } } class TestRefitAircraft extends MoneyTest { v = null; c = null; function DoAction() { if (AIExecMode() && AIVehicle.RefitVehicle(v, c)) { return true; } AIVehicle.SellVehicle(v); return false; } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIVehicle.RefitVehicle(v, c); return cost.GetCosts(); } function TryRefit(vehicle, cargoId) { v = vehicle; c = cargoId; return DoMoneyTest(); } } class TestRemoveAirport extends MoneyTest { l = null; function DoAction() { if (AIExecMode() && AIAirport.RemoveAirport(l)) { return true; } return false; } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIAirport.RemoveAirport(l); return cost.GetCosts(); } function TryRemove(airport_location) { l = airport_location; if (DoMoneyTest()) { return true; } return false; } } /* BuildManager.nut */ class TestDemolishTile extends MoneyTest { l = null; function DoAction() { return AIExecMode() && AITile.DemolishTile(l); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AITile.DemolishTile(l); return cost.GetCosts(); } function TryDemolish(location) { l = location; return DoMoneyTest(); } } class TestRemoveRoadStation extends MoneyTest { l = null; function DoAction() { return AIExecMode() && AIRoad.RemoveRoadStation(l); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIRoad.RemoveRoadStation(l); return cost.GetCosts(); } function TryRemove(location) { l = location; return DoMoneyTest(); } } class TestBuildRoad extends MoneyTest { s = null; e = null; function DoAction() { return AIExecMode() && AIRoad.BuildRoad(s, e); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIRoad.BuildRoad(s, e); return cost.GetCosts(); } function TryBuild(start, end) { s = start; e = end; return DoMoneyTest(); } } class TestBuildTunnel extends MoneyTest { t = null; l = null; function DoAction() { return AIExecMode() && AITunnel.BuildTunnel(t, l); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AITunnel.BuildTunnel(t, l); return cost.GetCosts(); } function TryBuild(vehicleType, location) { t = vehicleType; l = location; return DoMoneyTest(); } } class TestBuildBridge extends MoneyTest { t = null; i = null; s = null; e = null; function DoAction() { return AIExecMode() && AIBridge.BuildBridge(t, i, s, e); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIBridge.BuildBridge(t, i, s, e); return cost.GetCosts(); } function TryBuild(vehicleType, bridgeId, start, end) { t = vehicleType; i = bridgeId; s = start; e = end; return DoMoneyTest(); } } class TestBuildRoadStation extends MoneyTest { l = null; e = null; t = null; i = null; function DoAction() { return AIExecMode() && AIRoad.BuildRoadStation(l, e, t, i); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIRoad.BuildRoadStation(l, e, t, i); return cost.GetCosts(); } function TryBuild(location, exit, vehicleType, stationId) { l = location; e = exit; t = vehicleType; i = stationId; return DoMoneyTest(); } } class TestBuildDriveThroughRoadStation extends MoneyTest { l = null; e = null; t = null; i = null; function DoAction() { return AIExecMode() && AIRoad.BuildDriveThroughRoadStation(l, e, t, i); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIRoad.BuildDriveThroughRoadStation(l, e, t, i); return cost.GetCosts(); } function TryBuild(location, exit, vehicleType, stationId) { l = location; e = exit; t = vehicleType; i = stationId; return DoMoneyTest(); } } class TestBuildRoadDepot extends MoneyTest { l = null; e = null; function DoAction() { return AIExecMode() && AIRoad.BuildRoadDepot(l, e); } function GetPrice() { local cost = AIAccounting(); AITestMode() && AIRoad.BuildRoadDepot(l, e); return cost.GetCosts(); } function TryBuild(location, exit) { l = location; e = exit; return DoMoneyTest(); } } /* Route.nut */ class TestBuildRoadVehicle extends MoneyTest { d = null; e = null; v = null; function DoAction() { v = AIVehicle.BuildVehicle(d, e); if (!AIVehicle.IsValidVehicle(v)) { return false; } return true; } function GetPrice() { return AIEngine.GetPrice(e); } function TryBuild(depot, engine) { d = depot; e = engine; if (DoMoneyTest()) { return v; } return null; } }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever