Jump to content

Recommended Posts

Posted

I would like to have the function of "subroutine call & return" in 3D-Modellbahn Studios as implemented in other languages.

Posted

Hallo / hello @hmclay,

definiere im Modellbahn-Studio ein Benutzer-definiertes Ereignis und rufe dieses in einem anderen Ereignis mit der Aktion "Benutzer-definiertes Ereignis auslösen" auf.
Define a user-defined event in the Train Studio and call it up in another event with the "User-defined event" action.

Beachte aber bitte, dass das Verhalten einer Subroutinen mit Rückkehr zum Aufrufer nach Beendigung der Subroutine nur dann funktioniert, wenn die Subroutine (das Benutzer-definierte Ereignis) keine Aktion "Ausführung verzögern" enthält. Betrachte hierzu das beigefügte Anlagen-Beispiel:
Please note, however, that the behavior of a subroutine with return to the caller after completion of the subroutine only works if the subroutine (the user-defined event) does not contain a "Defer execution" action. Please refer to the attached example:

Subroutine Demo.mbp

SubroutineDemo.thumb.jpg.e20e4367d3fff6591453e5f4a9858857.jpg

Schalte bitte das Ereignisprotokoll ein, um den Ablauf beim Drücken des obigen Buttons verfolgen zu können:
Please activate the event trace to be able to follow the process when pressing the above button:

Ereignisprotokoll.jpg.39f303d30a831757c87096d8b9ea388e.jpg

Wird der Button aktiviert, ergibt sich der im obigen Bild links dargestellte Ablauf: Das Hauptereignis ruft das Benutzer-definierte Ereignis "Subroutine 1" auf, das wiederum ein weiteres Ereignis "Subroutine 2" aufruft. Nach Beendigung des jeweiligen Benutzer-definierten Ereignisses kehrt der Ablauf in das aufrufende Ereignis zurück und wird dort fortgesetzt.
If the button is activated, the sequence shown in the above image on the left results: The main event calls the user-defined event "Subroutine 1", which in turn calls another event "Subroutine 2". Once the respective user-defined event has been completed, the sequence returns to the calling event and is continued there.

Wir der Button deaktiviert, durchläuft das Benutzer-definierte Ereignis "Subroutine 1" eine Zeitverzögerung (siehe den Ablauf rechts). Diese bewirkt, dass das Ereignis "Subroutine 1" an dieser Stelle beendet und nach Ablauf der Wartezeit in einem neuen Prozess fortgesetzt wird. Die Beendigung der "Subroutine 1" bewirkt eine sofortige Rückkehr zum aufrufenden Hauptereignis, dessen Ablauf somit ohne Abwarten der Zeitverzögerung fortgesetzt und beendet wird (siehe die Uhrzeit [12:24:38]). Subroutine 1 wird dagegen erst nach Ablauf der Wartezeit 5 Sekunden später ([12:24:43]) fortgesetzt, wo das aufrufende Hauptereignis längst beendet ist.
If the button is deactivated, the user-defined event "Subroutine 1" runs through a time delay (see the process on the right). This has the effect that the "Subroutine 1" event ends at this point and is continued in a new process after the delay time has elapsed. The termination of "Subroutine 1" causes an immediate return to the calling main event, whose process is thus continued and terminated without waiting for the time delay (see the time [12:24:38]). Subroutine 1, on the other hand, is only continued after the delay time has expired 5 seconds later ([12:24:43]), when the calling main event has long since ended.

Die Nachbildung einer synchronen Subroutine mithilfe des Benutzer-definierte Ereignisses funktioniert also nur, wenn in der Subroutine keine Zeitverzögerung eíngebaut ist.
The simulation of a synchronous subroutine using the user-defined event therefore only works if no time delay is built into the subroutine.

Viele Grüße / many greetings
BahnLand

Posted (edited)

Hello,

... I deleted the text because I misinterpreted something...

... ich habe den Text gelöscht, da ich etwas falsch interpretiert habe...

Gruß / greetings
EASY

Edited by EASY
Posted

I would like to have subroutine call/return in 3D Train Studio . Guessing it may be quite an involved undertaking. But sure would be a welcomed addition.

Put a request in the supplied forum here ... 

Posted

3D Train Studio already supports subroutines. What are you trying to achive and what have you already tried?

Kind regards,

Neo

Posted

If I understand @BahnLand example, it was written in Lua script language.

What I was trying to infer was that subroutine call and return be included in Train Studio language .

I have tried using script condition within an event, then go and perform a task and come back to the event, however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s).

Am I explaining adequately, or do I not understand how to use Train Studio Language correctly. I am not proficient in Lua, so I only use it sparingly and mostly from published routines or very small math and crane operations.

Therefore would like to have the function in Train Studio Language.

Posted
vor 4 Stunden schrieb hmclay:

however the calling event goes to the next line of code without waiting for the script to complete

This is an expected behavior of an event-driven, object-oriented language.

Posted

Hallo / hello @hmclay,

vor 6 Stunden schrieb hmclay:

If I understand @BahnLand example, it was written in Lua script language.

Nein! / No!
In der Ereignisdefinition des obigen Demo-Beispiels existiert keine einzige selbst geschriebene Lua-Zeile. Der komplette Ablauf wurde ausschließlich mit der grafischen Ereignisverwaltung realisiert.
In the event definition of the demo example above, there is not a single self-written Lua line. The entire process was realized exclusively with the graphical event management.

LeereUser-Ereignisse.thumb.jpg.41d570ca9f0381b3a33fa80465cec1d5.jpg

Die Trace-Ereignisse dienen ausschließlich der Ereignisprotokollierung. Sie besitzen keinen Inhalt.
The trace events are used exclusively for event logging. They have no content.

Ereignis-Aufrufe.thumb.jpg.2a81eff9cf7ca4c6489d00fca3a03326.jpg

Es genügt, das Benutzer-definierte Ereignis "Trace 1" (mit 1 Parameter) oder "Trace 2" (mit 2 Parametern) aufzurufen, um im aktivierten Ereignisprotokoll einen entsprechenden Trace-Eintrag zu erzeugen.
It is sufficient to call up the user-defined event "Trace 1" (with 1 parameter) or "Trace 2" (with 2 parameters) to generate a corresponding trace entry in the activated event trace.

Sinn und Zweck des obigen Beitrags war, nur mithilfe solcher Trace-Einträge den Ablauf aufgerufener "Unterprozedur"-Abläufe mit und ohne Zeitverzögerung - mit Mitteln der grafischen Ereignisverwaltung - zu visualisieren.
The purpose of the above article was to visualize the flow of called "sub-procedure" sequences with and without defer execution - using graphical event management - only with the help of such trace entries.

Viele Grüße / many greetings
BahnLand

Posted

I Posted: however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s).

Phrontistes Responded:

11 hours ago, Phrontistes said:

This is an expected behavior of an event-driven, object-oriented language.

OK ....  I understand - it's a limitation of object-oriented language. I will continue my work arounds as others have done now that I know it's not possible.

If I need to wait for a called user defined  event to finish, I can handle that. I now know that I'm not mis-interpreting the use of user-defined or script-condition.

Thanks to Phrontistes and BahnLand and NEO and all, for consideration and clarification.

Posted

Hi,

vor 16 Stunden schrieb hmclay:

have tried using script condition within an event, then go and perform a task and come back to the event, however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s).

You can export your 3D Train Studio project as an .mbp file and then publish it here as an attachment. That way we can see what you have done.
Du kannst dein 3D Train Studio Projekt als .mbp Datei exportieren und dann hier als Anhang veröffentlichen. So können wir nachsehen, was du gemacht hast.

Bild001.jpg.8f0d2b8615801a3cc18b52509a5025c2.jpg

Bild002.thumb.jpg.b4180a64a025c9dbaa3d9cd8349a551d.jpg

greetings
EASY

Posted
vor 2 Stunden schrieb hmclay:

I now know that I'm not mis-interpreting the use of user-defined or script-condition.

Really?

There is (unfortunately) no user-defined script-condition.

There is

  • a user-defined event on the one hand and
  • a script-condition on the other

These are two completely different things.

Kind regards

Phrontistes

Posted (edited)

That's why I stated User Defined   OR   Script Condition.  The word or was sort of hidden because I emphasized the two  commands. Sorry !

I did realize there was a difference !

Enjoying V9 ..... one problem I had is the program bombed out on me twice tonight while laying track and using slopes. Displayed a succession of error messages quickly, then jumped completely out of the program. Lost my work twice. Darn Bug's will show their face on new versions !

 

Edited by hmclay
changed "or messages" to "of messages"
Posted (edited)
10 hours ago, Phrontistes said:

Did you send the error message to the developer? You should always do that.

No Sir, didn't get a chance. Multi messages appeared in successive overlays very quickly then the whole screen went blank before I could even read them. Unless there is a file that records them, I haven't a clue what the code is. 

Edited by hmclay
Added response
Posted (edited)
vor 3 Stunden schrieb hmclay:

Multi messages appeared in successive overlays very quickly

This was a known bug in V 7 or V 8 when driving into a portal with the cockpit camera turned on. Which version are you using? Look here:

Screenshot2024-11-21215649.jpg.9a9c4d2be3b649b94c71c70affe0a358.jpg

vor 3 Stunden schrieb hmclay:

Unless there is a file that records them

No, there is no such file Yes, see Neo's answer below

Edited by Phrontistes
Posted
vor 3 Stunden schrieb hmclay:

Unless there is a file that records them

Yes there is an error file which is stored in "C:\Users\<User>\AppData\Local\3D-Modellbahn Studio V9". But this file is deleted once you restart the app, so it is only useful directly after the crash.

Posted (edited)

@Neo and @Phrontistes

Attaching error file from error I have been experiencing.

Happens when editing track and it seems to happen during slope adjustment.

I changed the extension from .log to .pdf so I could sent here. I was able to open it in notepad.

Error.pdf

Edited by hmclay
wording
Posted (edited)

Do you use V 9.0.1.8? Sorry, the question is superfluous, you can see that in the log file.

The .pdf is damaged. I overlooked that you only changed the extension but did not convert the .log to a .pdf.

Edited by Phrontistes
Posted
vor 5 Stunden schrieb hmclay:

I changed the extension from .log to .pdf so I could sent here.

Better send it to Neo's email address and without the name change!
Use "Kontakt" at the bottom of this page to find his email.

kind regards
Goetz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...