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 Members
  
  Please can someone help me with the following.
  I am trying to build a table containing all the Locomotives
  in the layout. I cannot find the Lua code corresponding to
  "the vehicle has an engine" in the following:  
  
  function GetAllLocos()
      local tt = {}
      g = layout:enumVehicles(
      function ( vehicle )
         if "the vehicle has an engine" then
           table.insert(tt,vehicle)
         end
      end
      )
      return tt
  end
  
  I have searched the forum for quite a long time before making
  this request. I hope some kind person will tell me the solution.
  
  Thank you
  
  Eric
  
  ----------------------------------------
  Google translation:
  Bitte kann mir jemand bei folgendem helfen.
  Ich versuche eine Tabelle mit allen Lokomotiven zu erstellen
  im Layout. Ich kann den entsprechenden Lua-Code nicht finden
  "Das Fahrzeug hat einen Motor" im Folgenden:
             <Lua function>
  Ich habe das Forum ziemlich lange durchsucht, bevor ich es gemacht habe
  diese Anfrage. Ich hoffe, eine freundliche Person wird mir die Lösung sagen.
  
  Vielen Dank

  Eric
 

Geschrieben

layout:enumVehicles(
function(vehicle)
   print(vehicle:hasEngine())
end )

Geschrieben

function GetAllLocos()
      local tt = {}
      layout:enumVehicles(
      function ( vehicle )
         if vehicle:hasEngine()  then
           table.insert(tt,vehicle)
         end
      end
      )
      return tt
  end

Bearbeitet von HaNNoveraNer

Geschrieben
  • Autor

Thank you HaNNoveraNer

I had a memory of "hasEngine" but I was trying vehicle.hasEngine. Once again: thanks for your quick reply.

Best wishes

Eric

 

Geschrieben

@Eric Danvers 

Hello Eric,

I don't know if you know this

for information

all Lua functions and properties are documented directly in the script editor by auto-completion Press colon (:) for a list of all functions, 
dot (.) for a list of all properties and 
CTRL+space for an overview of all global variables and parameters.

NEO has answered a question from TIMBA
every vehicle has the function "hasEngine", with which you can check if it is a powered vehicle

local vehicles = layout:getVehiclesOnTrack(...)
for k, v in pairs(vehicles) do
  if v:hasEngine() then
    -- Vehicle ist eine Lok
  end
end
 

Best wishes

Martin

Geschrieben
  • Autor

Hello Martin

I tried .(dot) CTRL+space but not :(colon) CTRL+space. I won't make that mistake again!

Best wishes

Eric 

Geschrieben
vor 20 Stunden schrieb Eric Danvers:

I was trying vehicle.hasEngine.

That would be a variable or property. Separated by a single colon.

The double colon is needed for a function or method. It includes the object (= what's in front of the colon) as the first argument.

Bearbeitet von Goetz

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.