Results 1 to 4 of 4

Thread: Problem mit String Erzeugung

  1. #1

    Question Problem mit String Erzeugung

    Hallo,

    ich bastel an einem String, dass meine Planeten reaktivieren kann.
    Und händisch kann ich natürlich den String zu ActivateBuiliding(Position As String, Status As Boolean) eingeben,
    aber ich hätte es gern automatisch.

    Der Compiler ist mit meiner Ausführung zufrieden,
    aber die Ausführung erzeugt leider einen BlueScreen, der meiner Lesweise nach etwas mit dem String zu tun hat.

    Kann mir jemand einen Verbesserungvorschlag machen? Danke.


    Code:
    #UseInterface Web;
    
    Var Kolo1 As New CMyColony(XXXXX); //Kolonie eintragen
    //unveränderliche Variablen
    Var ScriptName As String = "PlanetOn";
    Var form As New CHtmlForm(New CScriptUrl());
    Var tab As New CTable(2);
    Var row As CTableRow = tab.AddRow(); 
    Var Action As CBaseColonyManager;
    Var IntA As Integer = 0;
    Var IntB As Integer = 0;
    Var KoloPos As String;
    
    form.Add(tab);
    
    While(IntAB < 70)
    {
      KoloPos = CStr(IntA) + '|' + CStr(IntB);
      If(Kolo1.StockRoom.Amount(EGoodsType.Deuterium > 100)) 
      {
        Kolo1.Action.ActivateBuilding(KoloPos, True);
        row = tab.AddRow();
        row.Cells.Item(0).Add('Gebäude aktiviert.');
        row.Cells.Item(1).Add(KoloPos);
      }
      IntB = IntB + 1; If(IntB = 10){IntB = 0; IntA = IntA + 1;}
      IntAB = (IntA * 10) + IntB;
    }
    
    Response.Add(form);
    Die Fehlermeldung dazu:
    Das Script hat einen Laufzeitfehler verursacht. Zeile: 21, Spalte: 5, Token: 'Kolo1', Script: 'PlanetOn'

    [IndexOutOfRangeException: Index was outside the bounds of the array.]
    at stne.TPlanetMap.get_Item(Int32 x, Int32 y) in d:\source\dragon\dev1\projects\stne\game\Core\MapL ib.cs:line 284
    at stne.ScriptTypes.CBaseColonyManager.GetFieldID(Str ing Position) in d:\source\dragon\dev1\projects\stne\game\Scripting \Objects.cs:line 2422
    at stne.ScriptTypes.CBaseColonyManager.ActivateBuildi ng(String Position, Boolean Status) in d:\source\dragon\dev1\projects\stne\game\Scripting \Objects.cs:line 2428

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeIn ternal(Object obj, Object[] parameters, Object[] arguments)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    at larne.Scripting.Legacy.TScriptObjectMemberNative.G etValueInternal(TLarneScriptContext Context, Object obj, Object[] Index) in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 2671
    at larne.Scripting.Legacy.TScriptObjectMemberNative.G etValue(TLarneScriptContext Context, TCodeExpressionObjectMember CallExp, Object obj, Object[] Index) in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 2660
    at larne.Scripting.Legacy.Expressions.TCodeExpression ObjectMember.Get(TLarneScriptContext Context) in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\ScriptExpressions.cs:line 376
    at larne.Scripting.Legacy.Commands.TCodeCommandExpres sionCall.Process(TLarneScriptContext Context) in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\ScriptCommands.cs:line 80
    at larne.Scripting.Legacy.TLarneScriptContext.Execute Internal() in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 1198

    [Exception: Das Script hat einen Laufzeitfehler verursacht. Zeile: 21, Spalte: 5, Token: 'Kolo1', Script: 'PlanetOn']
    at larne.Scripting.Legacy.TLarneScriptContext.Execute Internal() in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 1213
    at larne.Scripting.Legacy.TLarneScriptContext.Execute (Int32 StartLine) in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 1250
    at larne.Scripting.Legacy.TLarneScriptContext.Execute () in d:\source\dragon\dev1\projects\shared\larne.script ing\legacy\Script.cs:line 1285
    at stne.TLarneScript.ExecuteInternal() in d:\source\dragon\dev1\projects\stne\game\Core\Temp 3.cs:line 600
    at stne.TLarneScript.ExecuteInQueue() in d:\source\dragon\dev1\projects\stne\game\Core\Temp 3.cs:line 549
    at stne.wf_ScriptEdit.act_SaveSource(Boolean IsConfigSource) in d:\source\dragon\dev1\projects\stne\game\WebForms\ ScriptEdit.cs:line 864
    at stne.wf_ScriptEdit.ExecuteAction() in d:\source\dragon\dev1\projects\stne\game\WebForms\ ScriptEdit.cs:line 117
    at stne.TstneBasePage.CallExecuteAction() in d:\source\dragon\dev1\projects\stne\game\Core\WebC ontrols.cs:line 229
    at stne.TstneGamePage.CallExecuteAction() in d:\source\dragon\dev1\projects\stne\game\Core\WebC ontrols.cs:line 1061
    at stne.wf_ScriptEdit.Run() in d:\source\dragon\dev1\projects\stne\game\WebForms\ ScriptEdit.cs:line 98
    at stne.wf_Game.Page_Load(Object sender, EventArgs e) in d:\source\dragon\dev1\projects\stne\game\Game.aspx .cs:line 142
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Assembly: larne.scripting.dll
    Time: 07.03.2017 13:34:33
    Server: DE3
    User-ID: 32018
    STNE-Version: 1.0.74.1559
    Compiled at: 06.02.2017 19:44:52
    Compiled from: Dragon
    Last edited by quor; 08-03-2017 at 09:26.
    Ich schreibe kompliziert, weil ich 102 Tasten habe.

  2. #2

    String-Problem eingeengt

    Ok, das Problem ist, dass ich die Gebäude im Orbit nicht korrekt deklariere.

    Aber wie geht der korrekte String dazu?
    Leider gibt es ja bei CBuilding und bei CColonyField keine Property, die einem das ausgibt.

    Mit welchem Zusatz werden also die Gebäude im Orbit gekennzeichnet?

    Diese Antwort müßste doch Dragon kennen, oder???

    LG Quor
    Ich schreibe kompliziert, weil ich 102 Tasten habe.

  3. #3

    Cool Gebäude im Orbit haben die Position '@X|Y'

    Lieber Quor,

    habe mir die Scripte in der Scriptbibliothek nochmal intensiv angeschaut und dort insbesondere das Script: Planetenverwaltung.
    Danke an das Wesen mit den sensiblen Ohren,

    Die Weltraumgebäude haben das Präfix @ vor dem x|y

    Problem gelöst.

    Danke.
    Ich schreibe kompliziert, weil ich 102 Tasten habe.

  4. #4

    Smile Endgültige Lösung für ActivateBuilding

    Hallo,

    nachdem also der String für Gebäude im Orbit klar war: @X|Y
    Löste sich leider der Bluescreen nicht in Wohlgefallen auf.

    Dragon - danke - empfahl mir die Aktivierung über zwei For-Schleifen laufen zu lassen.

    Ok, nachdem ich verstanden hatte wie das geht, danke STNE-Wiki, habe ich das Script zum laufen gebracht.

    Code:
        For(IntB = 0 To 4)
        {
          For(IntA = 0 To 9)
          {
            KoloPos = CStr(IntA) + '|' + CStr(IntB);
            If(Kolo.FieldByID(Kolo.Map.Item(IntA, IntB).FieldID).HasBuilding = True And Kolo.BuildingByID(Kolo.Map.Item(IntA, IntB).FieldID).Active = False)
            {
              Kolo.Action.ActivateBuilding(KoloPos, True);
            }
          }
          row = tab.AddRow();
        }
        
        For(IntB = 0 To 1)
        {
          For(IntA = 0 To 9)
          {
            KoloPos = '@' + CStr(IntA) + '|' + CStr(IntB);
            If(Kolo.FieldByID(Kolo.OrbitMap.Item(IntA, IntB).FieldID).HasBuilding = True And Kolo.BuildingByID(Kolo.OrbitMap.Item(IntA, IntB).FieldID).Active = False)
            {
              Kolo.Action.ActivateBuilding(KoloPos, True);
            }
          }
          row = tab.AddRow();
        }
    Das komplette Script steht in der Script-Bibliothek unter dem Namen: PlanetOn
    Ich schreibe kompliziert, weil ich 102 Tasten habe.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •