dim3 Forum

Full Version: In game play messages/notifications
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Well i've been kinda playing with Dim for a few days now, poking around with the scripts, trying to make little levels and such. I'm not the best game maker person but i try to have fun with things like this.

Ok generic information I was wondering about possibly making in game notifications appear when the person playing approches a spot or picks up an item.

I'm sure there is a way to do it and with all the poking around i've done I haven't seen away to do that yet, so hoping that you really smart people can help me out here.
There a several ways to do this.
You can show/hide text or images. Look at the scripting documentation's interface object part.
(http://erikkemmer.er.funpic.de/dim3/docs...ject.html)
That's probably what you are looking for.
To create new text/images, edit the Data/Settings/Interface.xml.
Hope this helps.
The image goes in the data<bitmaps<interface folder (sorry if I got the < backwards, I can never remember which way they go).
edit: woh, I took way too long to type that.

Welcome!
It should be easy. An example of this is in the JoeFoe stalk script.
You can't do it (or at least not as easily) for spots, you'll just want to create an invisible object for the 'getting close to a location' part. Have the object set a watch
Code:
obj.watch.start(x);
where x is the distance you want it to react at.
In the event section, put an event like this:
Code:
case DIM3_EVENT_WATCH:
            watch(obj,subEvent);
            return;
This will trigger whenever a watch event happens. (This includes an object leaving or entering the watch radius)
In the function, add this:
Code:
if (subEvent==DIM3_EVENT_WATCH_OBJECT_NEAR) {
        if (obj.watch.objectIsPlayer) y;
Where y is then the message that is shown.
If for whatever reason you want something to happen when it leaves the radius, change the 'near' to 'far'. Not sure why its worded like that, kinda confusing.

If you want a message of text or an image on the screen, take a look at the player script for where it draws the ammo bullets and writes the name of the weapon thats selected. You can do sound too, but thats fairly self explanatory (look at the docs).
Thanks for help!
Though my scripting skill is limited to very simple c++ and I might show a bit of 'idiot' when i ask this: This question is about getting close to an object and seeing a message appear, can I just dull down a JoeFoe so that its just an invisible thing that only has a watch for my player?

also Gordan said "Where y is then the message that is shown". That can't be just typing the message I want to appear, could it?
Yes but I don't reccomend it.

Here, I'll write one really fast for you, don't expect me to do this alot but I want to show you how it works. Look it over and see if you understand it.
Code:
//**********MESSAGE***********
//Set parameter 0 on the spot to the distance that sets it off
//Set parameter 1 to the text it shows (type {r} for a line break)
//Play around with the number (currently 20) at the obj.event.chain line to decide how long before the message goes away
//I HAVE NOT tested this so there might be some errors, post with the error and I'll help you
//You'll need to make a empty text in the interface script called "Message".
//******************************
function messageConstruct(obj)
{
    obj.setting.suspend=true;

    obj.size.x=1200;
    obj.size.z=1200;
    obj.size.y=2000;
}

function messageSpawn(obj)
{
    obj.watch.start(obj.setting.getParameter(0));
}

function messageWatch(obj,subEvent);
{
    if (subEvent==DIM3_EVENT_WATCH_OBJECT_NEAR) {
        if (obj.watch.objectIsPlayer==true) {
            iface.text.set('Message',obj.setting.getParameter(1));
            iface.text.show('Message');
            obj.event.chain(20,'hideText');
        }
    }

}

function hideText(obj)
{
    iface.text.hide('Message')
}

//
// events
//

function event(obj,mainEvent,subEvent,id,tick)
{
    switch (mainEvent) {
    
        case DIM3_EVENT_CONSTRUCT:
            messageConstruct(obj);
            return;
    
        case DIM3_EVENT_SPAWN:
            messageSpawn(obj);
            return;

        case DIM3_EVENT_WATCH:
            messageWatch(obj,subEvent);
            return;
            
    }
}
Right, the way ccccc showed it.
I was just using Y to show where the script bits went, I was too lazy too go through the other stuff. Rolleyes
There was one syntax error, some semicolon being evil was it, as for any semantic errors, i'm not sure. I haven't got a message to appear on screen yet.

Not to particulary worried about it now, looking at this script and comparing it to the others, I think i'm begining to see how its actually working call it weird but i like to learn how things work not just 'doing' it. I'm going to have to thank you again for this one.

iface.text.set('Message',obj.setting.getParameter(1));

Correct me if i'm wrong but does this action take the string in parameter 1 and put it into a text file 'Message'?
Jacree Wrote:There was one syntax error, some semicolon being evil was it, as for any semantic errors, i'm not sure. I haven't got a message to appear on screen yet.
What was the error?

Jacree Wrote:Not to particulary worried about it now, looking at this script and comparing it to the others, I think i'm begining to see how its actually working call it weird but i like to learn how things work not just 'doing' it. I'm going to have to thank you again for this one.
Thats not weird. Thats the point of me showing you how Wink. I showed you how so you could look at it and understand how dim3 scripts work, not just so you could use it (though you can use it too of course!). Everyone here is like that, either that or they won't be here for long.

Jacree Wrote:iface.text.set('Message',obj.setting.getParameter(1));

Correct me if i'm wrong but does this action take the string in parameter 1 and put it into a text file 'Message'?
Yes, pretty much. It doesn't save it to a file though, it sets the text. As in, if the text says "FOO" you could set it to "SOMETHING ELSE" so it would say "SOMETHING ELSE" instead of "FOO". There IS an error somewhere and there's always the chance that thats the syntax error and I typed it wrong, but yes, thats what I intended it to do.
Well the console says in line 22 "Missing before function body"

function messageWatch(obj,subEvent);

is that suppose to have a semicolon on it?
Pages: 1 2 3
Reference URL's