dim3 Forum

Full Version: Coins?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know there are old posts about coins but i am not sure if they are out dated, as i could not find the lines of script mentioned.
If some one could send me in the right direction it would be greatSmile
What exactly are you talking about here?
Coins? As in Super Mario?
Objects that the player touches, they play an anim, disappear and add score?
Or something else?
Sorry, pick up coins for a game currency.
I still don't really understand what you're talking about.
However, I decided to post a script that might be useful to you (or others).
It's the crystal script from my still not finished single player version of OrigamiBots.
I tried to comment every line, so it should be easy to understand.

Code:
//
// crystal SCRIPT
//

// This is a crystal object that sends a message to the course script, which then increases the crystal variable by one.
// It can be turned on/off using messages and can send a message to the course script when picked up (for example triggering movements, etc.)

// Spot parameters are:
// 0 - standard off? (0 or 1)
// 1 - send message on pickUp? (0 or 1)
// 2 - message id (id of message to send if the above is 1)

    var off;
    var msgOn;
    var msgId;


// CONSTRUCT
function crystalConstruct(obj) {

    obj.setting.contact=true; //contact with other models
    obj.setting.pickUp=true; //can be picked up
    obj.model.on=true; //has a model
    obj.model.lit=DIM3_MODEL_LIT_VERTEX; //vertex lighting to make it look goooood :P
    obj.model.name='crystal'; //model name
    obj.model.offset.y=-500; //float in the air, 500 model units above ground
    obj.model.bounce=true; //bounce up and down
    obj.model.spin.y=3; //spin around y-axis
}

// PICKUP
function crystalPickUp(obj) { //upon pickup

    obj.event.sendMessageToCourse(301); //send a message to the course script to increase score
    if (msgOn) obj.event.sendMessageToCourse(msgId); //if set to true in the parameter, send another message to course script
    obj.setting.contact=false; //no more collision
    obj.setting.hidden=true; //hide the object
    obj.setting.pickUp=false; //you can't pick it up again

}

// MESSAGE
function crystalMessage(obj,subEvent,id) { //when receiving a message

    switch(id) { //act depending on the id of the message

        case 1: //1 = activate the crystal
            off = 0; //it's not off
            obj.setting.hidden=false; //not hidden
            obj.setting.contact=true; //and contact = true
            return;

        case 2: //2 = deactivate it
            off = 1; //it's off
            obj.setting.hidden=true; //hidden
            obj.setting.contact=false; //and has no collision
            return;
            
    }

}

// SPAWN
function crystalSpawn(obj) {//when spawning

    off = parseInt(obj.setting.getParameter(0)); //get the object parameter
    if(off) obj.setting.hidden=true; //and turn the object off, if needed

    msgOn = parseInt(obj.setting.getParameter(1)); //parse some integers and set variables
    if(msgOn) msgId = parseInt(obj.setting.getParameter(2)); //lol
    

}


// EVENT
function event(obj,mainEvent,subEvent,id,tick) {

    switch (mainEvent) {

        case DIM3_EVENT_CONSTRUCT:
            crystalConstruct(obj);
            return;

        case DIM3_EVENT_SPAWN:
            crystalSpawn(obj);
            return;

        case DIM3_EVENT_MESSAGE:
            crystalMessage(obj,subEvent,id);
            return;

        case DIM3_EVENT_PICKUP:
            crystalPickUp(obj);
            return;

    }

}

Ok so after re reading this post: http://www.idevgames.com/dim3/showthread.php?tid=1304 i now have coins but how do i:

1: Add a coin count (like grenade count)

2: Use these to buy stuff in game eg add weapons (if i need to learn to script for this i was wondering if there are any good tutorials out there (I've read Alexander Smiths one but it made no sense to me)).
That's a tutorial of it's own, Bink. Smile With all those comments I could read right through it and understand a lot of it. Using a script and explaining what's going on really makes it easier. Maybe sometime you could make more like that.

PatrickA Wrote:
That's a tutorial of it's own, Bink. Smile With all those comments I could read right through it and understand a lot of it. Using a script and explaining what's going on really makes it easier. Maybe sometime you could make more like that.


I actually have more like that, but not commented that well.
If I added more comments, they'd probably be just like this one.
I didn't think anybody would be interested in random scripts. O_o

Im also making armor as a pickup but i dont know what to tell it to do, i think it is show mesh 'Armor'.
Reference URL's