Author Topic: I have a mod with a simple script. SP error "Can't start local game server"  (Read 2659 times)

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
So I'm working on a relatively simple mod with a single script in it. Its got a on ship destroyed handler (does nothing but a console output right now). However, whenever I tried to start a game with it I get an error "Can't start local game server.

So I copied the contents from collision.js into my script and tried again. Same error. I changed the *name* of my script to collision.js and suddenly it works. Are we not allowed to add new scripts? we have to modify/use ones already there?

-Loudent

MenschMaschine

  • Full Member
  • ***
  • Posts: 104
    • View Profile
What would be the name of your script?
No Berries!

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
I tried different names. The last one was JettisonCargo.js

Does it matter?

MenschMaschine

  • Full Member
  • ***
  • Posts: 104
    • View Profile
I would guess there is some form of list of assets which are loaded by name.
Compared to a method where every *.js file in a given folder within the scripts-hierarchy
would be loaded and processed by the engine.

You also could try one of the JS-validation websites to be really really sure
that there are no errors. (no offense meant :) )
No Berries!

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
No offense taken, but when I literally copied one of the existing scripts into mine I can be reasonably sure there are no errors. Only difference is the name.

jeeplaw

  • Newbie
  • *
  • Posts: 46
    • View Profile
In the header of the file, do you have any USING or INCLUDE statements?

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
In the header of the file, do you have any USING or INCLUDE statements?

Yes, of course.

Also, In my last test, I copied over the collision.js from the core pack into my mod, tested it and it worked, changed the name from collsion.js to something like lcollsion.js (no code changes) and it fails. If you want I could post the mod somewhere and you can look at it.

MenschMaschine

  • Full Member
  • ***
  • Posts: 104
    • View Profile
That would help, yes.
No Berries!

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
That would help, yes.

Ok, here's a mod named coltesta.mpk
https://www.dropbox.com/s/akjy52r3widd88g/coltesta.mpk?dl=0

and here's a mod named coltestb.mpk
https://www.dropbox.com/s/jfz229bvyjno08x/coltestb.mpk?dl=0

The only difference (between module names) is that the script in coltesta is named collisiox.js and the file in coltestb.mpk is called collision.js

coltesta.mpk does not work (with the aforementioned error) and coltestb.mpk *does* work

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Follow up. It appears the problem is the location. I had both files in data\scripts\global in my mod structure. If I move the collisiox.js out of global (say down to the scripts directory) it works again.

Well, it loads. I have yet to get it to work with a script

« Last Edit: April 19, 2015, 12:32:56 pm by loudent »

MenschMaschine

  • Full Member
  • ***
  • Posts: 104
    • View Profile
That's weird. Although, it remembers me of two shipmods that i tried.
Flessens Enterprise and N1c0's Nebula-1C0 both have their hull-data lying outside of the usual frigate, cruiser, other folders
and it still works.
No Berries!

ai_enabled

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 1041
    • View Profile
loudent, have you tried running the game server in multiplayer mode? It will output the errors. In that case the errors are:
Code: [Select]
[ERR] data/scripts/global/collisionb.js: action.Create() error: Action was already created: OnProjectileHitShip
[ERR] data/scripts/global/collisionb.js: action.Create() error: Action was already created: OnDebrisCollided

It means that the other script has been already added these actions. You cannot call
Code: [Select]
actions.Create("OnProjectileHitShip");
actions.Create("OnDebrisCollided");
in another script as it already called from the original script.
That's why the copy-pasted script with a different name is not working.

Regards!