dim3 Forum

Full Version: Using non default player script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone.

Please excuse my noobishness as this is the first thread I have started. I'm trying to figure out if I have simply missed something or stumbled onto a legitimate bug with using non-default player script files.

From what I can tell, the executed player script is defined in the map file under the spot id like this:

<Spot id="0" c3="50,209,50" name="Start" type="Player" script="**scriptName**" display_model="" params="" angle="0" />

However changing **scriptName** to any other script name still seems to load the default. In fact, changing the name to an invalid / non existent filename doesn't seem to crash the game either.

Is there another reference to the default script I have to change, or is this something which is a known issue? Any help on this matter would be greatly appreciated!
First: Why don't you change it in Editor? Don't mess around with the map.xml files. You might f*ck things up.
Second: I think it always loads Player.js. I've never managed to make it load anything else.
There is, however, something that I've not tried yet.
In the map script (Scripts/Courses/<mapname>.js) there is this code:
Code:
    for (i=0;i!=cnt;i++) {
        name=map.spot.getName(i);
        type=map.spot.getType(i);
        if ((type=='Object') || (type=='Bot')) {
            map.spot.attachObject(i,name,type,map.spot.getScript(i),map.spot.getParameter(i));
        }
    }
Looks like it's responsible for attaching the scripts to the spots...
Maybe if you change it to something like
Code:
    for (i=0;i!=cnt;i++) {
        name=map.spot.getName(i);
        type=map.spot.getType(i);
        if ((type=='Object') || (type=='Bot')) {
            map.spot.attachObject(i,name,type,map.spot.getScript(i),map.spot.getParameter(i));
        }
        if (type=='Player') { //if its the player spot
            map.spot.attachObject(i,name,type,"non_default_player.js",map.spot.getParameter(i)); //attach a different player script named "non_default_player.js"
        }
    }
it could work. The player script might as well be hard-coded into the engine to always be Player.js.
I'm not quite sure.
I tried it out and It didnt do what it was supposed to, but did this cool thing anyhow.
the player wasnt using the other player script. oddly, there was a model using the other player script where I Spawned, and when I shot him I the screen turned sideway like I died, and the Unused model died; yet I was still alive with the screen turned sideways. it was kinda cool. Smile
Yes, trying to use a different player script messes things up, usually you end up with 2 players.
Why would you want a different script? (besides to try to make the P lowercase :P)
Thanks for the response people!

It's not really a major concern - it's more that the editor gave me the impression that that's how it is indeed supposed to work. You can attach the name of a different script to the spawn point, so it follows that should be the one being used.

I suppose you can do neat things like give the player different profiles / stats by changing them during run time and editing the variables that way rather than defining them in a new player script?
Kurohyou Wrote:I suppose you can do neat things like give the player different profiles / stats by changing them during run time and editing the variables that way rather than defining them in a new player script?

Absolutely.
Reference URL's