Jump to content

Zugriffsverletzung


Herman

Empfohlene Beiträge

Hello Developers, hello members. Sorry I'm here again with something strange.
I get this error with some script, the script is triggered by a track contact.
It works fine, but not always

distribute.thumb.jpg.1639c46aa4d47f1be5a7a257c2fb6c0c.jpg

local depotA  = vehicle.variables["#AUa Depot"]
vehicle.variables["#AUa Depot"]:add(vehicle)
if depotA.count > 0 then
 depotA:release(0)
end


You can only see the error in the analyser, the result is that a car is not released from his local depot.

Some help please. I will try to make a little .mbp with only this problem in it.
Greetings Herman
 

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hello Herman,

vor 5 Minuten schrieb Herman:

Some help please.

Judging by the error message, I'd guess that
you attempted to send a car, with no valid depot address stored in #AUa Depot, to that very depot.

And why don't you use the variable depotA in line 2?
And why don't you post code in this form, please?

local depotA  = vehicle.variables["#AUa Depot"]
depotA:add(vehicle)
if depotA.count > 0 then
    depotA:release(0)
end

And what's with that hash tag at the beginning of the variable's name?

 

You may want to check the stored information for validity, before you use it.
And maybe print some error message when the variable doesn't hold anything useful.

See if that helps to catch the culprit.

Goetz

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hello @Goetz , thank you for your answer. Feedback.

 

32 minutes ago, Goetz said:

And why don't you use the variable depotA in line 2?

yes,  but cannot generate the error, and this line is executed ok

34 minutes ago, Goetz said:

And what's with that hash tag at the beginning of the variable's name?

All my objects that are used somewhere in an event starts with a # and some unique identification + a name, ex: #AU Opel01. All the variables of that object do use the start ex:
#AU Maxspeed. I have an own naming convention. Because I often use generic events I must be aware that keywords are unique. The rest is to easy find out wich variable is from a specific object. But that's my stuff.  ( and yes I am aware that you can count the elements of a table with # )

 

41 minutes ago, Goetz said:

You may want to check the stored information for validity, before you use it.

That's for sure. So I agree it can be a distraction.

I'm now testing, and will report soon.

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hello, still testing and yet the "Bösewicht" is still here.
If I send a car in with an empty name of the depot to come out I do not get that error message but this one.
With an incorrect object name the next.

497303018_vehicletodepot.jpg.ce489260adfeddcc4fe24942e94dbad6.jpg

38678211_incorrectobj.jpg.684ad50c78e205a95ffeb6126a12daa8.jpg

Then the vehicle does not even go to the depot. In my case it goes to the depot, and mostly comes out correct. But sometimes we get the error.
Still searching, sorry,

Greetings, Herman

Bearbeitet von Herman
Link zu diesem Kommentar
Auf anderen Seiten teilen

Hello @Neodevelopers, members, Goetz,

For the moment I stop searching.  There are only 4 cars running, and I triple checked their variable. The layout where the error occurs is this one : 
5E7583EB-A086-47F5-891C-5172D0FB9BDE ( draft ).
It is a starting layout with a lot of tracks and streets that demonstrates a specific crosspoint in my neighbourhood.  But the code is minimal. 

Normally I get this

173084571_noerror.thumb.jpg.b7297b8d59bf437295871871183163ab.jpg

Sometimes but far not always :( the error haunts. So I cannot reproduce it in a very short time. However it appears frequently, and with different cars.

error.thumb.jpg.90544a69acd8aa75c5881293af1b386b.jpg

You can notice the error  outside the analyser because that depot has a vehicle in it, and it should release it immediately. ( below the base plate )

Greetings, Herman


 

Bearbeitet von Herman
Link zu diesem Kommentar
Auf anderen Seiten teilen

Hello Herman,

It looks like the car is already counted, but not ready yet for retrieval.

Anyway, now that I know what you're attempting, I have a suggestion:
"car arrives at depot" is an event that you can respond to.

 

138107897_carentersbluedepot.jpg.fb4b8f3344d5d42f16fbb0beacbfbea4.jpg

 

That's the safe way to send out the car which has just arrived.
Two commands in immediate succession for sending and retrieving the car leaves the studio no time to actually perform the transaction from contact to depot. 

Greets
Goetz

 

Bearbeitet von Goetz
Link zu diesem Kommentar
Auf anderen Seiten teilen

12 hours ago, Goetz said:

Two commands in immediate succession for sending and retrieving the car leaves the studio no time to actually perform the transaction from contact to depot. 

Yes, sometimes... , certainly not always...

Hello @Goetz , that has probably caused the error, I was thinking in that direction, however, the advice of an expert here is always top. Thanks for your suggestion, a very good one !  Nevertheless I was looking primarily what caused the error. 
I 'm already working in another way. Just for the record, for what I want to do it is better to send the car directly to the depot where it belongs, without central depot, and a timer per depot can let them out randomly. ( let the car restart in the depot where he started before to maintain his target, just experimenting another street traffic )

For me this post can be closed, thank you very much @Goetz !
Kind regards, Herman

Link zu diesem Kommentar
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto besitzen, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen.

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...