I need help with item and shape icons with this Minimap


(Camos1011) #1

I found a really cool Minimap that does everything I want except for the ability to assign special icons to the object on the radar (i.e. keys, shapes, landmark, items, etc.).
I need help with being able to do that.
Been trying to figure this out all day.

MiniMapV4_2.blend (535.3 KB)

Thank you!


(- Click for resources) #2

gamelogic_simple.py

objects are using property tracked.
in the above script they set the color

you could also look/use mine, my version uses a plane(or any object) as representation of the objects and you can make/bake your own map.


(Camos1011) #3

I tried using yours earlier and yours with the one I’m using is just making me a million times more confused.


(Camos1011) #4

I figure it has something to do with Layer 2 on Scene.001 is where the other item objects should go along with the Token object but, that’s where I get stuck.


(- Click for resources) #5

because only that token thingy is being used as representation.
you add a property tracked to your building (like the other object have) then in script you add a color.

if you want other things you need to script it yourself into it. That’s why i recommended my own, it already has multiple options.

In my version:
add property ‘minimap’,string, a_name.ico.
go to minimap scene layer 2, add object/plane and give that object the same name as the property.

now it wil show the building. But if you create your own map, you can just bake the building/landmarks onto it, then you don’t even need to use an icon.


(Camos1011) #7

That’s the thing, I don’t want the map part. Just where objects image icon (i.e. image of a key) and enemies are relative to the player to keep from spoiling the rest of the level.
I just want a simple radar.

If I thought it was as easy as simply coding these details I wouldn’t be here asking for help.
It’s not so easy for me. Knowing what to put is one thing. The where is my biggest problem.


(Lyeb) #8

Read the code.

SendTargets writes a list of object info, converts it to a string and sends it as body of a message.
gamelogic_simple is connected to the sensor that is listening for these messages.
What it does then is turn the body string back into a list to access this information.

Going by index, the list contains:

  • at [0]: a string for object name
  • at [1]: a vector for world transforms
  • at [2]: a string which is used as a flag, to determine object color (green, red or blue)

What you need to do is send additional information within this list.
One could, for instance, send the name of an icon’s mesh to replace the token’s.
The name of the icon could be grabbed directly from an object property to save time.

My advice is that you learn more python.


(- Click for resources) #9

Ok, i commented out 3 lines in my code to disable the background for you and added it to the download in my topic.

  • add a building give it a property ->minimap-string-name_for_icon.ico
  • go to minimap scene layer 2 and add an object, give it the same name as the property you have added on that object (name_for_icon.ico).
  • go back to layer 1, go back to main scene, hit play.

(Camos1011) #10

It would be nice to have it at an angle like the project I uploaded.
The project I’m working with is 2D and this project radar’s orientation does a great job at telling where the object is on that levels above and below.

Is it really that hard to change or add more icons?
I just want to know the difficulty to know if I should do or if it’s out of my reach.
I’m still pretty newbish. Knowing which lines are what in detail would really help a lot given you guys know the nature of the project enough to say have tell me the nature of a line def.

I also tried tilting your project and that didn’t work.


(- Click for resources) #11
  1. Yes and no.
  2. it is

@Liebranca already explained it.

But ok here i added comments



                D = objects.worldPosition.z-own.worldPosition.z #calculate vector distance between object and player
                if abs(D) <.5: # if +D or -D is smaller then 0.5
                    SList.append([objects.name,[Store.x,Store.y,Store.z],'Green'])  #add this list to Slist
                else:
                    if objects.worldPosition.z>own.worldPosition.z: # if objects z position bigger then player/owner
                        SList.append([objects.name,[Store.x,Store.y,Store.z],'Red']) #add this list to Slist
                    else: #if objects z position smaller then  or does not exist or throwing error then player/owner
                        SList.append([objects.name,[Store.x,Store.y,Store.z],'Blue']) #add this list to Slist


Info = eval(Message.bodies[0])
        for Data in Info: #loop trough the information the other script send to here
            if Data[0]!="Player":
                Added = bge.logic.getCurrentScene().addObject('Token',own,1) #adds the token/icon object
                if Data[2]=='Red': #if the send color is red
                    Added.color = [1,0,0,1]
                if Data[2]=='Blue':
                    Added.color = [0,0,1,1]     
                if Data[2]=='Green':
                    Added.color = [0,1,0,1]    
                    
                Added.worldPosition=own.worldPosition+Vector([Data[1][0]*.1,Data[1][1]*.1,Data[1][2]*.1]) # set the token/icon position + the offset data from the lists created in the other script.
                    

It’s a small but rather compact/complex script, for me it’s simple i don’t extend other users scripts.

For you it’s hard because you barely know python. For anyone not into this type of script it’s a pain as well due to the whole script needs to be altered in order to add more/other icons.

Don’t get me wrong it’s a neat lil script, but without knowing python it’s out of your reach (for now).


Aah what the peep. here you go, never say i didn’t help you :stuck_out_tongue:

ok what to do?

  • in Scene:
    – add your building/landmark
    – add 2 properties
    – 1.Tracked
    – 2. icon_to_use -> string -> name of the icon you going to use.

  • Scene.001:
    – go to layer 2
    – add an object you going to use as an icon
    – give it the exact same name as you used in the ‘icon_to_use’ property of your building/landmark

Tadaa, works great doesn’t it.

problem you have now is it won’t set color depending on height anymore, but with landmarks/buildings it should not be a problem i guess? If it is you figure it out :wink:

MiniMapV4_2_adjusted_by_cotaks.blend (606.9 KB)

Have fun with it.

  • Oh and check the scripts code from this blend and your blend, i have changed a few things.

(Camos1011) #12

I was so close but, didn’t think to use two properties instead.
What I was doing was:

    if 'init' not in own:
        own['init']=True
        own['TList']=[]  
    if Message.positive:
        own['Text']=Message.bodies[0]
        Info = eval(Message.bodies[0])
        for Data in Info:
            if Data[0]!="Player":
                Added = bge.logic.getCurrentScene().addObject('Token',own,1)
                if Data[2]=='Red':
                    Added.color = [1,0,0,1]
                if Data[2]=='Blue':
                    Added.color = [0,0,1,1]     
                if Data[2]=='Green':
                    Added.color = [0,1,0,1]    
           
           if Data[0]!="Item":
                Added = bge.logic.getCurrentScene().addObject('Torus',own,1)    
                if Data[2]=='Green':
                    Added.color = [0,1,0,1]  

However, all of the other objects would only be white Toruses.
I always avoided just putting it over the Player Color segment.
I just didn’t know where.

xDD It may not seem like I’m learning but, I am.
I just need the answer in front of me from time to time.
Individual commands and lines might as well be gibberish to me unless I understand it all together.
Hence, the bloated hover text logic in that 2.5d project.
Sometime I make half-assed solutions based on trial and error.

Anyway, thanks a lot dude!


(- Click for resources) #13

This will not work due to the very first thing the script reads

if Data[0]!="Player"

if data is not the same as player, and it isn’t so that script is executed.

Yup i know, we all start like that :wink:

and that’s how you learn from your mistakes and getting better at it.


(Camos1011) #14

I tried using this to assign new objects and it doesn’t work


(- Click for resources) #15

Did you only do that? Then try again :wink: it works.

Don’t forget to name the icon in layer 2 the same so if this is your string: ‘name of the icon you going to use.’ then the icon on layer 2 needs to be named as ‘name of the icon you going to use.’


(Camos1011) #16

Tried it both ways that you mentioned over and over and it still shows a cube when I have a torus and a sphere.
This makes no sense to me.


(- Click for resources) #17

well it works here, so something going wrong on your side

MiniMapV4_2_adjusted_by_cotaks.blend (705.3 KB)


(Camos1011) #18

It was an extra space in ‘icon_to_use’.
Spelled like this ‘icon_to _use’…

Derp! xDD

It works perfectly!
Thanks.
I’ll try not to bug you with my newbishness for a long time now!