Brauche ich getObject für setValue?

  • #1, by MachtnixSunday, 07. May 2017, 21:07 7 years ago
    Hallo, ich habe im Editor einen Wert angelegt, angenommen Test=0. Diesen Wert möchte ich in Lua auf 1 setzen. Muss ich dazu immer vorher ein getObject ausführen und jedesmal eine Variable dafür anlegen, wie im Scripting erläutert?
    -- set condition "TV is on" to true
     local cond = getObject("Conditions[TV is on]")
     cond:setValue(VConditionValue, true)


    Ich habe es mal frei interpretiert:
    Var = getObject("Values[Test]")
    Var:setValue(???????, 1) <---- was muss da rein??

    Logisch betrachtet, brauche ich doch keine Extra-Variable mit Doppelpunkt, wenn im setValue der komplette Pfad drin wäre, oder? (also nach der alten Schreibweise)

    Kann ich also einfach statt getObject(ganzer Pfad) setValue (ganzer Pfad) schreiben?

    Thread Captain

    1097 Posts


  • #2, by ke4Sunday, 07. May 2017, 21:25 7 years ago
    <font><font>Don't understand what you wrote, but try:</font></font><div>
    Values["test"].Int = 1
    Var = Values["test"]
    Var.Int = 1
    Maybe this could also work? Var:setValue(VValueInt, 1)

    Key Killer

    810 Posts

  • #3, by MachtnixSunday, 07. May 2017, 22:04 7 years ago
    Values["test"].Int = 1

    That works. Thanks.

    I don't know why, and what works and what not, because this Vis object thing isn't logical to me. I tried VValuesValue... (looks logical like the other constructs...)

    I prefer (seems a little bit more logical)
    Var:setValue(VValueInt, 1)

    but don't work.

    ... English isn't for me...

    Thread Captain

    1097 Posts

  • #4, by afrlmeSunday, 07. May 2017, 22:16 7 years ago
    Values["test"] is recent-ish shorthand Lua script that Simon implemented throughout the development of Visionaire Studio 4.

    However, Values["test"] is global, which means it will try to access a value called "test", but if you have more than 1 instance, then it will cause problems because it won't know which one to access. You either need to use unique names for every single scene object, character, value & condition or you can link directly to a specific one...

    game.CurrentScene.SceneValues["test"].Int = 1 -- set value "test" belonging to current scene to 1

    Scenes["example"].SceneValues["test"].Int = 1 -- set value "test" belonging to scene "example" to 1

    Scenes["example"].SceneObjects["some object"].ObjectConditions["test"].Int = 1 -- set value "test" belonging to scene object "some object" found on scene "example" to 1

    etc...

    Imperator

    7278 Posts

  • #5, by sebastianSunday, 07. May 2017, 22:17 7 years ago
    Values["test"].Int = 1

    That works. Thanks.

    I don't know why, and what works and what not, because this Vis object thing isn't logical to me. I tried VValuesValue... (looks logical like the other constructs...)

    I prefer (seems a little bit more logical)
    Var:setValue(VValueInt, 1)

    but don't work.

    ... English isn't for me...
    as mentioned a lot to you lately you have to study the DataStucture to know which object types have which (accessible) fields ^__^ 

    Wie schon so oft dir erläutert solltest du in der DataStructure schauen um zu sehen welche Objekt-Typen welche Felder haben

    Look here: https://wiki.visionaire-tracker.net/wiki/Data_Structure (scroll down to the "Value" Table) 

    Schau hier: https://wiki.visionaire-tracker.net/wiki/Data_Structure (Ganz unten in die "Value" Tabelle) 

    When you look up the Value table you will not find a "ValuesValue" field. Of course it looks logical in a way but accessing a field which does not exist doesnt help ... 

    Wenn du dir die Tabelle anschaust, wirst du da kein "ValuesValue" Feld finden. Natürlich schaut es in irgendeiner Weise logisch aus, aber das hilft dir nicht, wenn es dieses Feld nicht gibt ...

    These are the fields you can manipulate in a Value:
    ValueInt and ValueString. These are the only scriptable fields here. You may can get also the other fields content, but can't change it.

    Dies sind die Felder, die du bei einer Value bearbeiten kannst:
    ValueInt und ValueString. Diese sind die einzigen scriptbaren Felder hier. Du kannst ggf. auch die anderen Abfragen aber nicht aktiv ändern.

    Var:setValue(VValueInt, 1) will only work if you have "Var" defined as an object like you 
    mentioned:

    Var:setValue(VValueInt, 1) wird nur funktionieren, wenn du "Var" vorher definiert hast:
    Var = getObject("Values[Test]") ; Var:setValue(VValueInt, 1)

    So this will only work with the (long) getObject stuff .
    Or use it without creating a new lua variable:

    Dies wird auch nu mir der langen Methode funktionieren. Oder du nutzt ohnehin die kurze, schönere Schreibart:
    getObject("Values[Test]"):setValue(VValueInt, 1)

    -----

    The short forms just can use .Int (for ValueInt) and .String (for ValueString) behind the defining Object:

    Die Kurzformen können zudem auch .Int (für ValueInt) und .String (für ValueString) hinter der (kurzen) Objektdefinition genutzt werden:
    Values["test"].Int = 1
    Values["test"].String = "my text"

    EDIT: added german texts / deutschen text hinzugefügt

    Thread Captain

    2346 Posts

  • #6, by afrlmeSunday, 07. May 2017, 22:24 7 years ago
    @Sebastian: probably better off writing it in German for him. wink

    Imperator

    7278 Posts

  • #7, by MachtnixSunday, 07. May 2017, 22:36 7 years ago
    Because "Test" isn't global I tried

    Scenes["example"].SceneObjects["some object"].ObjectConditions["test"].Int = 1 -- set value "test" belonging to scene object "some object" found on scene "example" to 1


    and it works with ObjectValues. It isn't a condition. Thanks! That's what I want (the SURE long form: Universe.SolarSystem.Earth. Europe.Berlin.Alexanderplatz... wink

    Yes I printed out the Scripting and the Data Struktur ( smile ), I have a look every minute, but understanding what all this stuff means is another thing... I look at the examples, write into my script and put in the codes I hope they are correct in this case...



    Thread Captain

    1097 Posts

  • #8, by MachtnixSunday, 07. May 2017, 22:48 7 years ago
    @Sebastian: probably better off writing it in German for him. wink
    smile smile Thank you... Well I can understand most of it but sometimes ... I don't like English... Writing takes a long time... Years ago I wanted to write correct English but now I don't care if grammar or words are correct or not... I use the translation which is in my mind. I believe some native speakers smiles about it. I hope it's clear what I mostly want to say (if the problem is simple) but if the problem is heavy I prefer German.

    This text: 15 minutes.

    Thread Captain

    1097 Posts

  • #9, by MachtnixSunday, 07. May 2017, 23:15 7 years ago
    Ich befürchte, der Wertname "Test" ist im Lua-Script nicht derselbe Wertname wie "Test" im Editor (auch wenn es ihn nur einmal gibt). Also muss ich wohl doch dem Editor-Testnamen "Test" eine Lua-Variable "Test" zuweisen. Jedenfalls geschieht nichts, wenn ich mit "Test" in Lua rechne. OMG...

    I think, the name "Test" in the Lua script  isn't the same value object as the name "Test" in the editor. I can't use it. I first have to allocate a variable in Lua named "Test" to it, like: Test = getObject......["Test"]...


    Thread Captain

    1097 Posts