Page 1 of 1

"Defined var mismatch"?

Posted: Mon Mar 28, 2016 2:43 am
by rrTea
In one of the models in my project I have a following condition in the OnRender:
"return (NoiseBlink < 0.5);"
where the NoiseBlink variable is of float type. The whole OnRender component looks like this:

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Condition Comment="Should blink?" Expression="return (NoiseBlink < 0.5);">
  <OnTrue>
    <UseMaterial Material="mat_ColorMondrian"/>
    <RenderSetColor Color="0 0 0 1"/>
    <RenderMesh Mesh="mesh_Rectangle"/>
    <RenderSetColor Color="1 1 1 1"/>
    <RenderTransformGroup Name="transf_NoiseTile" Translate="0 0.1 0">
      <Children>
        <RenderTile Name="rendTile_noise" TileSet="tSet_RoomBkg"/>
      </Children>
    </RenderTransformGroup>
  </OnTrue>
  <OnFalse>
    <UseMaterial Material="mat_ColorMondrian"/>
    <RenderSetColor Color="1 1 1 1"/>
    <RenderMesh Mesh="mesh_Rectangle"/>
  </OnFalse>
</Condition>
So every time I click on this Model I get a red-bold type error in the console that says
"Defined var mismatch "NoiseBlink" in model "mod_Noise" must be at position 3 in Definitions-list."
(and the preview of the Model starts flashing),

What does that mean?

Re: "Defined var mismatch"?

Posted: Mon Mar 28, 2016 7:46 am
by VilleK
Hi,

Where is NoiseBlink defined? Try putting it in Model.Definitions list.

Re: "Defined var mismatch"?

Posted: Mon Mar 28, 2016 8:13 am
by rrTea
Hi Ville!
Yes, it's in the Model's definitions list. I tried moving it elsewhere too but no luck.

Edit: I forgot to mention, the project actually works perfectly (or at least that's what it looks like) when launched, both as a standalone and in Preview.

Edit 2: this Variable was originally in the BaseModel of this model, but I decided to move it from there to keep it better organized, which is when the trouble started. btw even if I delete the Variable & everything that is connected to it, and rewrite everything from scratch (using different variable names) the same error gets reported.

Re: "Defined var mismatch"?

Posted: Fri Apr 01, 2016 8:16 am
by rrTea
I moved the variable back to the model's BaseModel definitions, but that didn't help. Now I'm getting a similar error in other models too... Also any model that uses the same BaseModel (even the ones I make completely anew) report a "Defined Var Mismatch" as soon as I attempt to use any variables in the OnRender / Condition.

Re: "Defined var mismatch"?

Posted: Fri Apr 01, 2016 12:53 pm
by VilleK
If you move a variable between different Definition-list, you need to recompile the script before attempting to preview the model. This is because any variable that is in "Definitions" in a base/child-model relationship and is referenced in script code will have the location of the variable (the relative position in Definitions) in the compiled script code. So that can result in mismatch errors. Just closing/opening the project should fix it.

Re: "Defined var mismatch"?

Posted: Sat Apr 02, 2016 5:27 am
by rrTea
Just closing/opening the project should fix it.
I closed it and reopened it numerous times, but this doesn't seem to matter? In fact even if I attempt to write it from scratch in an empty ZGE project, it reports an error. I recorded it- please see attached.

Re: "Defined var mismatch"?

Posted: Sat Apr 02, 2016 4:30 pm
by VilleK
This is still only during preview of a model? And it works when running the app in preview and running standalone exe? I'm afraid that model preview of base/child models that have script code in OnRender using variables in Definitions can't work properly at the moment, because when you preview a model you are previewing the original model (i.e. not a clone). And the script that accesses variables in Definitions assume that it is running in a clone (base/child models only work with SpawnStyle=clone). A bit of a nuisance but hope that explanation makes sense.

Re: "Defined var mismatch"?

Posted: Sun Apr 03, 2016 2:02 am
by rrTea
Correct, that's only during preview of a model, and it works both as a standalone and when running a Preview.

Yes it makes sense, thanks for explaining! I just wish the model preview weren't flashing so much (you can't see it in the video but the whole preview starts flashing in real project)... Regardless - good to know it's nothing horrible!