Jump to content
Zum Start hinzufügen

Weitere Informationen

3D-Modellbahn Studio

Eine Vollbild-App auf Ihrem Startbildschirm mit Push-Benachrichtigungen und mehr.

So installieren Sie diese App auf iOS und iPadOS
  1. Tippen Sie auf das Teilen-Symbol in Safari
  2. Scrollen Sie durch das Menü und tippen Sie auf Zum Startbildschirm hinzufügen.
  3. Tippen Sie oben rechts auf Hinzufügen.
So installieren Sie diese App auf Android
  1. Tippen Sie auf das 3-Punkte-Menü (⋮) in der oberen rechten Ecke des Browsers.
  2. Tippen Sie auf Zum Startbildschirm hinzufügen oder App installieren.
  3. Bestätigen Sie durch Tippen auf Installieren.

Empfohlene Beiträge

Geschrieben

Hello,

I had some problems in a layout, but they are solved now. I know that Lua uses tables, so a list in the studio is made by Neo as a specific table?
But if possible some explanations from Lua experts on the forum. About the following:

A list OnTrain is declared as an event variable (or object variable), and filled with objects (copy or table.insert). After a while I want to initialise the list and did it with: /

InitList.jpg

Lua equivalent: $("Events").variables["OnTrain"] = {}

If you do so, the studio changes the list into a table with the same name. At first I did not noticed the change. The fact that the list is now a table gave problems in my layout.

Removing items in a list by position (or default) with table.remove will give a list with fewer items, as expected. Remove them all and you have an empty list.
Do the same with a table, we get a table with exact the same number of items as before, except they are now empty objects.

A little layout to illustrate this, and maybe normal behaviour? Test table remove.mbp

Is it possible to avoid this if using a table? So that a remove deletes the item as in a list.

Regards, Herman

Geschrieben

Hello @Herman ,

The same problem i'd have some times. The adding to such a list/table is ok. But removing an entry will destroy the list, if it had changed to table.
Therefor i did the following:

  1. copy the list/table in the same object, but with different variable name

  2. create a new empty list with the original variable name

  3. copy all remaining entries from the old copied list to the new created

  4. remove the temporay copied list

Perhaps it will help

Regards, Wolfgang

Geschrieben

Hi,

vor einer Stunde schrieb Herman:

Is it possible to avoid this if using a table? So that a remove deletes the item as in a list.

If the entry in a table is an object, a reference to this object is stored in the entry. With tabe.remove(item), this reference is set to nil, which still represents a valid entry.
Therefore, the number of table entries does not decrease.
One option is to first overwrite the reference with a number, for example. If the entry is now set to nil, it is deleted from the table.

You can try in the evert "remove"...

... change ...

local t = $("DHG 500 C").variables["OnTrain"] -- table
for i = 1,#t,1 do
  table.remove(t,1)
end

... into..

local t = $("DHG 500 C").variables["OnTrain"] -- table
for i = 1,#t,1 do
  t[i]=1
  t[i]=nil
end

(It may also be that there is another (better) solution)

EASY

Geschrieben
  • Autor

Hello @prinz , @EASY thanks for the suggestions,

Regards, Herman

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Push-Benachrichtigungen konfigurieren

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.