Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: SteelRat on March 28, 2015, 05:26:19 pm
-
/* file: scripts\test.js */
var test = ["test.js"];
/* file: scripts\test2.js */
test.push("test2.js");
/* file: scripts\test3.js */
test.push("test3.js");
/*
objdef: Logic
script: logic.js
*/
$include("scripts/test.js");
$include("scripts/test2.js");
$include("scripts/test3.js");
function init_chassis() {
}
function init_vehicle() {
_veh = this;
test.forEach(function (val, idx) {
_veh.log_inf("file is included: " + val);
});
/* Result
INFO: file is included: test.js
INFO: file is included: test2.js
INFO: file is included: test3.js
*/
}
function update_frame() {
}
-
Hmmmmmmmmmmm?
-
Hmmmmmmmmmmm?
The question?
-
Hmmmmmmmmmmm?
The question?
Not sure what this code is the answer too.......
-
/* file: myConstructor\car.js */
var engines = {
engine500Kwt: {
cylinderBlock: {
count: 8.0,
diameter: 0.120,
pistonStroke: 0.130
},
mainGear: 256/24
},
engine750Kwt: {
// ...
},
engine1000Kwt: {
// ...
}
}
var transmissions = {
transmission_1: {
gears: [128/24, 0.0, 128/24, 64/24, 32/24, 24/24], // [R, N, D0,...,Dx]
type: "Avtomatic"
},
transmission_2: {
// ...
},
transmission_3: {
// ...
}
}
/*
objdef: Car_1
script: Car_1.js
*/
$include("myConstructor/car.js");
function init_vehicle() {
this.engine = engines.engine500Kwt;
this.transmission = transmissions.transmission_1;
// ...
}
/*
objdef: Car_2
script: Car_2.js
*/
$include("myConstructor/car.js");
function init_vehicle() {
this.engine = engines.engine500Kwt;
this.transmission = transmissions.transmission_1;
// ...
}
/*
objdef: Car_3
script: Car_3.js
*/
$include("myConstructor/car.js");
function init_vehicle() {
this.engine = engines.engine1000Kwt;
this.transmission = transmissions.transmission_3;
// ...
}
Understand the meaning?
-
U create diferent options for choose one ingame? No idea..
-
Id say hes trying out multiple-file scripting for vehicles ... its actually a great thing.
If i get it right those first are defining there are three .js files to be and to be tested potentially (test1-3.js).
(first line just shows what .js file it is) var test = ["test.js"]; defines a file being a variable and test.push("test2-3.js"); as prolongation of variables .... the logic.js is then the main .js file hat has the function set to search for any files included with test.forEach(function (val, idx) {
_veh.log_inf("file is included: " + val);
}); ... on witch OT gives these messages in the error log :
INFO: file is included: test.js
INFO: file is included: test2.js
INFO: file is included: test3.js (... you just left it before function update frame to let people know right in script, what kind of messages should be shown in OT later.)
then there you try an analog whyt possible engine-characteristics ... are you trying to make an script for testing out multiple sets of engine propertyes ? Actually i would be really interested if something like that could be applied specifically to actual style wheel-definitions, cause that could lead to being able to set aether a flat tire, or changing of tire-airpressure (mainly diameter and grip) !!!
Also, additional functionalityes could be keept out of the main script (like gauges animation scripts of the main pannel, functionality stuff to other elements of the car, oppen-able stuff) witch would be great for my ural to keep a variety of scripts inter-vehicle-type usable or at least keep the changes in aditional stuff in a separate file to not mess up some things during theyr tweaking/rewrites ...
-
Thanks for the help PytonPago!
Я хочу верить что не будет нарушением правил если я воспользуюсь при общении с вами языком, которым я владею лучше чем международным.)
Если я правильно понял, у вас есть вопросы. Но транслятор не дал возможности понять более конкретно, что вас интересует. Я с удовольствием отвечу на ваши вопросы.
И у меня к вам просьба, попросите от моего имени администрацию форума создать параллельно этой ветке такую же с префиксом RU.
Это даст возможность мне и другим, таким же как я, более развёрнуто, и более качественно доносить некую информацию сообществу.
А для интересной и полезной темы всегда найдётся хороший человек), который сделает качественный перевод и репост в международную ветку.
-
Я хочу верить что не будет нарушением правил если я воспользуюсь при общении с вами языком, которым я владею лучше чем международным.)
Если я правильно понял, у вас есть вопросы. Но транслятор не дал возможности понять более конкретно, что вас интересует. Я с удовольствием отвечу на ваши вопросы.
И у меня к вам просьба, попросите от моего имени администрацию форума создать параллельно этой ветке такую же с префиксом RU.
Это даст возможность мне и другим, таким же как я, более развёрнуто, и более качественно доносить некую информацию сообществу.
А для интересной и полезной темы всегда найдётся хороший человек), который сделает качественный перевод и репост в международную ветку.
" I hope it wont be a too much problem to use my native language as i dont do good with the multinational.
As i understand, ya have some questions, but the translator didnt really do good ... just ask what ya like.
I have also a little thing to ask , for the administrators, if a topick o the same in RUss, in paralel to this one, could be created so i and my kindsmen could contribute a little more to it. Well, there will be always someone who would be able to translate that one here into ENG. "
---- SteelRat - ill translate it when i find time to do so at each post of you cirilic users ... no problem. As for those questions, they didnt much understand what those scripts were about, but i have done a little explaining in my last post (i hope its correct).
-
Я хочу верить что не будет нарушением правил если я воспользуюсь при общении с вами языком, которым я владею лучше чем международным.)
Если я правильно понял, у вас есть вопросы. Но транслятор не дал возможности понять более конкретно, что вас интересует. Я с удовольствием отвечу на ваши вопросы.
И у меня к вам просьба, попросите от моего имени администрацию форума создать параллельно этой ветке такую же с префиксом RU.
Это даст возможность мне и другим, таким же как я, более развёрнуто, и более качественно доносить некую информацию сообществу.
А для интересной и полезной темы всегда найдётся хороший человек), который сделает качественный перевод и репост в международную ветку.
" I hope it wont be a too much problem to use my native language as i dont do good with the multinational.
As i understand, ya have some questions, but the translator didnt really do good ... just ask what ya like.
I have also a little thing to ask , for the administrators, if a topick o the same in RUss, in paralel to this one, could be created so i and my kindsmen could contribute a little more to it. Well, there will be always someone who would be able to translate that one here into ENG. "
---- SteelRat - ill translate it when i find time to do so at each post of you cirilic users ... no problem. As for those questions, they didnt much understand what those scripts were about, but i have done a little explaining in my last post (i hope its correct).
Yes, you correctly translated my idea. Thank you!
-
Ah ha! So it is possible to include multiple javascript files! Excellent! I tried and just didn't define the include correctly. Thank you very much!
Regards,
Uriah
-
Ah ha! So it is possible to include multiple javascript files! Excellent! I tried and just didn't define the include correctly. Thank you very much!
Regards,
Uriah
Это предоставляет широкие возможности скриптинга.
Вы можете иметь одну копию файла с неким кодом, которую можете использовать во многих местах.
Как результат код выглядит не так массивно, легко читаемо, структурировано, то есть легко ориентироваться.
-
Это предоставляет широкие возможности скриптинга.
Вы можете иметь одну копию файла с неким кодом, которую можете использовать во многих местах.
Как результат код выглядит не так массивно, легко читаемо, структурировано, то есть легко ориентироваться.
"It will broathen the use of scipts.
You can have a copy of a code file, witch can be used at multiple objects. Also, the code wont be so massive, will be more structured and good for orientation"
-
Hi cameni!
RU
Я имею пользовательскую папку
D:\Outerra_data\packages\Ptm
Эта папка содержит библиотеку функций и созданных объектов("JScript").
Содержимое этой библиотеки используется для создания конструктора("vehicle.js") в разных пакетах с объектами.
Это разумно, иметь один экземпляр данных, которые используются совместно разными пакетами. Многие объекты имеют общие(одинаковые) свойства и методы.
Так же это упрощает процесс создания логики, и внесение изменений в уже созданную логику. Изменения будут применяться сразу ко всем пакетам использующим данные из библиотеки. Это очень упрощает, и организует работу.
Проблема в реализации этого в том, что метод "$include()" не позволяет обратиться к папке которая размещенна, в иерархии папок, выше.
Я догадываюсь, что вы, скорее всего, имеете свой вид на этот аспект, и в будущем это будет как то реализованно.
Но пока не настало светлое будущее, дайте пожалуйста энтузиасту "SteelRat" возможность навигации по пользовательской папке "D:\Outerra_data\packages" c помощью метода "$include()".
Translate
I have a custom folder
D:\Outerra_data\packages\Ptm
This folder contains a library of functions and objects("JScript") created.
The contents of this library used to create a constructor ("vehicle.js") in different packages with objects.
It is prudent to have one copy of the data that are shared by different packages. Many of the objects have in common (same) properties and methods.
It also simplifies the process of logic, and amendments to the already created logic. The changes will apply to all packages use the data from the library. This greatly simplifies and organizes the work.
The problem of this implementation is that the method of "$include()" does not allow the address to which the layout folder in the folder hierarchy, above.
I guess that you are likely to have your view on this aspect, and in the future it will be as it implemented.
But while it is not bright future, please give the enthusiast "SteelRat" the opportunity to navigate the user folder "D:\Outerra_data\packages" by "$include()".
-
This will be addressed, but it will be a compromise between the convenience of development and the need to avoid dependency and versioning hell. Basically, $include will allow you to address libs with common functionality outside of the package directory, but model exporter will pack all dependencies into the package so that the model can function in standalone way too.
-
but model exporter will pack all dependencies into the package so that the model can function in standalone way too.
Awesome!