"Defined var mismatch"?

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

"Defined var mismatch"?

Post 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?
Last edited by rrTea on Mon Mar 28, 2016 8:15 am, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: "Defined var mismatch"?

Post by VilleK »

Hi,

Where is NoiseBlink defined? Try putting it in Model.Definitions list.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: "Defined var mismatch"?

Post 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.
Attachments
QQ浏览器截屏未命名.png
QQ浏览器截屏未命名.png (5.09 KiB) Viewed 8922 times
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: "Defined var mismatch"?

Post 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.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: "Defined var mismatch"?

Post 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.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: "Defined var mismatch"?

Post 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.
Attachments
Capture-112 (1).avi
Recorded on a different computer.
(944.07 KiB) Downloaded 341 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: "Defined var mismatch"?

Post 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.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: "Defined var mismatch"?

Post 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!
Post Reply