Author Topic: obj.touch.objectIsBot problems  (Read 2695 times)

DomReardon

  • Full Member
  • ***
  • Posts: 19
    • View Profile
    • Email
obj.touch.objectIsBot problems
« on: September 01, 2014, 12:53:43 AM »
I can't seem to get 'obj.touch.objectIsBot' to work. Here's my script-
Code: [Select]
if(obj.touch.objectIsBot){
iface.console.write('BOT');
}
Which should just write 'BOT' in the console when a bot touches my object, but it doesn't, I've tried with my own bot and with the demo one and I definitely have them set as 'Bot' in the editor.
I tried 'obj.touch.objectIsPlayer' and that worked fine, I also tried 'if(obj.touch.objectName=='whatever'){etc}' and this works fine too. So it feels like my object isn't recognising bots... maybe I need to do something in settings or something...

ggadwa

  • Administrator
  • Full Member
  • *****
  • Posts: 201
    • View Profile
    • Klink! Software
Re: obj.touch.objectIsBot problems
« Reply #1 on: September 03, 2014, 07:26:52 AM »
I can't seem to get 'obj.touch.objectIsBot' to work. Here's my script-
Code: [Select]
if(obj.touch.objectIsBot){
iface.console.write('BOT');
}
Which should just write 'BOT' in the console when a bot touches my object, but it doesn't, I've tried with my own bot and with the demo one and I definitely have them set as 'Bot' in the editor.
I tried 'obj.touch.objectIsPlayer' and that worked fine, I also tried 'if(obj.touch.objectName=='whatever'){etc}' and this works fine too. So it feels like my object isn't recognising bots... maybe I need to do something in settings or something...

That function could have probably been named better, when it refers to "bot", which gets used in different places, it's really a "player bot", which is the kind of things you launch when in multiplayer (if you played a multiplayer game and said "add 10 bots", those would be the bots.)

I'd stick to the =='whatever' for now, to look for specifically named objects.

[>] Brian

DomReardon

  • Full Member
  • ***
  • Posts: 19
    • View Profile
    • Email
Re: obj.touch.objectIsBot problems
« Reply #2 on: September 04, 2014, 01:55:31 PM »
Ah, I see.
Basically, what I'm trying to do is make a script for a trap which goes off when an enemy touches it, but it shouldn't go off if anything that is not an enemy touches it. Which, if all my enemy are called 'Steve' wouldn't be a problem, but if I have 50 enemies with unique names and say 20 traps then things are gonna start to get really complicated. So what I'm really after is a way of putting objects into groups and then detecting which group they are in. So for me one group might be called 'monsters' but I don't want to actually name all my monsters 'monster' because sometimes I will need them to behave individually, so they need individual names. Is there anything like this already in place?

ggadwa

  • Administrator
  • Full Member
  • *****
  • Posts: 201
    • View Profile
    • Klink! Software
Re: obj.touch.objectIsBot problems
« Reply #3 on: September 04, 2014, 04:27:58 PM »
Ah, I see.
Basically, what I'm trying to do is make a script for a trap which goes off when an enemy touches it, but it shouldn't go off if anything that is not an enemy touches it. Which, if all my enemy are called 'Steve' wouldn't be a problem, but if I have 50 enemies with unique names and say 20 traps then things are gonna start to get really complicated. So what I'm really after is a way of putting objects into groups and then detecting which group they are in. So for me one group might be called 'monsters' but I don't want to actually name all my monsters 'monster' because sometimes I will need them to behave individually, so they need individual names. Is there anything like this already in place?

Nothing like that, but you could do the opposite -- if only players and monsters are moving around, if it's (!obj.touch.objectIsPlayer) could work.  Or if you named them with something similar in them like "sewer monster" and "sky monster" you could always check (obj.touch.objectName.indexOf('monster')!=-1) to see if this object has "monster" as part of it's name.

[>] Brian

DomReardon

  • Full Member
  • ***
  • Posts: 19
    • View Profile
    • Email
Re: obj.touch.objectIsBot problems
« Reply #4 on: September 05, 2014, 01:18:50 AM »
Perfect! (obj.touch.objectName.indexOf('monster')!=-1) Sounds like it will do exactly what I'm after, thanks Brian.