Jump to content
The Dark Mod Forums

Script redeclaration problem?


grayman

Recommended Posts

I started WS2:Home Again using the latest SVN (15447/7824) and got this error:

 

"ERROR: Error: file maps\ws2_homeagain.script, line 59: Type mismatch on redeclaration of length"

 

The line in question is:

 

float length = gybbsPlayer.startSoundShader(recording,1);
startSoundShader returns a float to the thread where the line in question appears.
The odd thing is the claim that the line redeclares "length" when this is the only declaration of "length" in the script file.
Anyone been fiddling with types lately?
Thx.
Link to comment
Share on other sites

That looks like a naming conflict, is that a map script or a object script? If is a map script did you put your code inside a namespace, to make it unique? If is a object script you need to use define guards to prevent conflicts.

 namespace mapname { 
     map code 
} 
#ifndef __SOMESCRIP__
#define __SOMESCRIP__

object code here

#endif //__SOMESCRIP__

hope this helps.

Link to comment
Share on other sites

If I had to hazard a guess, I suspect that the HRTF merge may have added data attributes to that audio

lookup and now it's getting bad data back?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Stgatilov.

 

Now that I think about the error more, "length" might now be a reserved word in scripting?

 

Maybe that was done with stgatilov's changes to resolution handling.

 

Does replacing it with au_length or some other variable name fix it?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

It looks like it's conflicting with the existing float length(ev_vector) function

Personally I'm clueless but is it possible that @stgatilov fixed the typeinfo in a way that the scripts now have access to the underlying type methods?

ev_vector is based on IdVec3.

 

We do seem to have scriptEvent float vecLength(vector vec) already though.

 

@grayman I'm curious why you put the script file in the pk4/maps folder rather than in pk4/script? Is that where all fm scripts must go to?

Link to comment
Share on other sites

OK, here it is

darkmod\script\trigger_look.script

float length(vector v) {
	return sys.sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
}
Revision: 14617
Author: springheel
Date: вторник, 1 ноября 2016 г. 23:06:31
Message:
obs look scripts
----
Added : /trunk/script/ai_trigger_look.script
Added : /trunk/script/trigger_look.script


@grayman, your first instinct might be to rename length in your map script however I suggest removing the function in trigger_look and replace its usage to vecLength as the latter is the binary code and is obviously faster.

Link to comment
Share on other sites

@grayman, your first instinct might be to rename length in your map script however I suggest removing the function in trigger_look and replace its usage to vecLength as the latter is the binary code and is obviously faster.

 

Nay nay, my first instinct is not to change my script.

 

There are at least 54 mission-supplied scripts already out there, and it's incumbent on us to not screw them up.

 

The question I would ask is : How many of them now won't run due to the recent changes.

 

The recent changes must be made to live with the released missions.

 

Of course, once those changes are made, we are now forced to verify there's been no further damage, and all of these missions must be started with the first 2.07 beta candidate to ferret out any other namespace collisions.

  • Like 1
Link to comment
Share on other sites

@grayman I'm curious why you put the script file in the pk4/maps folder rather than in pk4/script? Is that where all fm scripts must go to?

It's been that way since day 1.

 

From the wiki page:

 

"Using a plain text editor create a blank file with the same name as your map, eg, testScripts.script and save it in the same folder as your map."

  • Like 1
Link to comment
Share on other sites

Yes. I looks like Springheel was trying to help the community by making Obsttorte's script part of the core mod.

Too bad it conflicts with the existing script. This probably never came up before because it was only ever used

as a custom script in mission packs. The best course of action is to change the newest one.

 

Removing trigger_look and it's entry in the master custom script file resolves this.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Yes. I looks like Springheel was trying to help the community by making Obsttorte's script part of the core mod.

Too bad it conflicts with the existing script. This probably never came up before because it was only ever used

as a custom script in mission packs. The best course of action is to change the newest one.

 

Removing trigger_look and it's entry in the master custom script file resolves this.

 

Those look scripts have been part of the core mod for more than two years and have been through two different beta-testing cycles. Why would they just start causing problems now?

  • Like 1
Link to comment
Share on other sites

 

Those look scripts have been part of the core mod for more than two years and have been through two different beta-testing cycles. Why would they just start causing problems now?

 

Because you added them to tdm_custom_scripts.script in rev 15443 December 15th 2018

 
+//#include "script/tdm_ropescroller.script"
+#include "script/ai_trigger_look.script"
+#include "script/trigger_look.script"
 

when you tried removing the New Job scripts from TDM.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

OK. I applied Duzenko's workaround to trigger_look and now WS2 loads again in Trunk.

 

How about in the 2.07 branch? That's where we're supposed to be making changes from now until 2.07 ships and we can switch back to the trunk.

 

Edit: The 2.07 branch still crashes.

Link to comment
Share on other sites

Well, that would definitely explain it. Not sure what happened there, but thanks for fixing it.

Link to comment
Share on other sites

 

How about in the 2.07 branch? That's where we're supposed to be making changes from now until 2.07 ships and we can switch back to the trunk.

 

Edit: The 2.07 branch still crashes.

I'll do that once 207 branch has finished downloading.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

  • 1 year later...

I revisted this thread because I recently got this a redeclaration error with this in my <fm>.script function:

some_function_name(entity bob, ...)  {...}

I was getting a "Type mismatch due to redeclaration of 'bob'" error. After wasting buckets of time looking at my code, I found this forum thread, and realized it's just a naming conflict with some "bob" function in the standard distribution.

And specifically \tdm_base01\script\tdm_events.script(270): scriptEvent void        bob(float speed, float phase, vector distance);

But what's insidious here is that the conflict is with a local function parameter name, and any decent language would not make this a conflict. Because of that assumption, it took me a longer time to realize the cause, and the easy solution to just rename the parameter. (Namespace as HMart mentioned above would work too).

Maybe this is not a language design issue, just a parser bug. Don't know.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...