Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: check wether an entity is in a region or not  (Read 4418 times)

0 Members and 1 Guest are viewing this topic.

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
check wether an entity is in a region or not
« on: March 30, 2006, 06:04:46 PM »

Hello again

is it possible to check if an entity is inside a specific region or not ??
and how is it done if possible ??

i want to achieve a kind of masking effect.  if its inside its active, if its outside its inactive ...

Greets
stucki

DukeS

  • WME User
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 20
  • I'm Guybrush, a mighty pirate!
    • View Profile
Re: check wether an entity is in a region or not
« Reply #1 on: March 30, 2006, 06:18:41 PM »

Logged
How to code right if alignment is set left ...

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: check wether an entity is in a region or not
« Reply #2 on: March 30, 2006, 09:58:31 PM »

thanks for answering, but thats the solution for actors. Is it possible to check if a normal entity or sprite is in a region ??
maybe i can do it by creating 50 actors, but thats not exactly what i want to do ...

i want to have little dustballs floating around in moonlight thats shining through a window. and they become invisible if they leave the moonbeam ...
just for some atmosphere ...

how can it be achieved.

i cannot make a png with a hole and let them fly behind it because of some other scene layers....
Greets
stucki

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: check wether an entity is in a region or not
« Reply #3 on: March 30, 2006, 10:19:20 PM »

It will work for entities too. As you can see, the base of that code is the Scene.GetRegionAt() method, which returns a region at certain scene coordinates. It's up to you where you obtain the coordinates and it doesn't matter it they come from actor's position or from an entity or from anywhere else.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: check wether an entity is in a region or not
« Reply #4 on: March 30, 2006, 11:46:01 PM »

okay i see and i tried it but i cant get to work it properly.

i have to scripts.
the first the emitter ...
Code: [Select]
#include "scripts\base.inc"

var ANZAHL = 30;
var staubEntities = new Array(ANZAHL);
for (var i=1; i<20;i=i+1)
{
staubEntities[i] = Scene.CreateEntity();
var temp = staubEntities[i];
temp.X=Random(600,1280);
temp.Y=Random(450,1000);
temp.AlphaColor = RGB(255, 255, 255, 0);
temp.SetSprite("sprites/funke.sprite");
temp.Active=true;
temp.Interactive=false;
temp.AttachScript("scripts/staub.script");
Sleep(5);
}

i=i+1;
while (true)
{
staubEntities[i] = Scene.CreateEntity();
temp = staubEntities[i];
temp.X=1280;
temp.Y=Random(450,1000);
temp.AlphaColor = RGB(255, 255, 255, 0);
temp.SetSprite("sprites/funke.sprite");
temp.Active=true;
temp.Interactive=false;
temp.AttachScript("scripts/staub.script");
i=i+1;
Sleep (Random(50,500));
}

it brings the dust to live

second the script for the movement of the created sprites:
Code: [Select]
#include "scripts\base.inc"

var Reg;

while (true)
{
this.X=this.X+Random (-3/1);
if (this.X<500) break;
this.Y=this.Y+Random (-2/2);

Reg = Scene.GetRegionAt(this.X, this.Y);
if (Reg == "strahl") this.AlphaColor = RGB (255,255,255,Random(150,200));
else this.AlphaColor = RGB (255,255,255,0);
Sleep(20);
}

Scene.DeleteEntity(this);

but my dustparticels remain always invisible ....
whats wrong with it ??

by the way what kind of region is the right one (tried both, and none worked) the region for the walkborders(white) or the entityregions (green) ??
and is it possible to get counts below zero with the Random command maybe Random(-5,5); ?!?

as alway thanks for helping so much !!!! O0

Greets
stucki

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: check wether an entity is in a region or not
« Reply #5 on: March 31, 2006, 10:41:47 AM »

Quote
whats wrong with it ??
I see one obvious mistake:

Reg = Scene.GetRegionAt(this.X, this.Y);
if (Reg == "strahl") ...

should be

if (Reg.Name == "strahl") ...

"Reg" is a region object, not a string.

Quote
by the way what kind of region is the right one (tried both, and none worked) the region for the walkborders(white) or the entityregions (green) ??
We're talking about scene regions, not region entities.


Quote
and is it possible to get counts below zero with the Random command maybe Random(-5,5);
Um, you got me here. I think it should work, but better try it ;) But even if it wouldn't, you can always do something like Random(0, 10) - 5.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: check wether an entity is in a region or not
« Reply #6 on: March 31, 2006, 01:19:03 PM »

thanks so far.

now i got it and i am able to check wether the dustparticle is in or out of the region.
but for any reason i dont get them to be displayed when they are in the region

if (Reg.Name == "strahl") this.AlphaColor = RGB (255,255,255,Random(100,255));
else this.AlphaColor = RGB (255,255,255,0);
so they should be visible, but they are not !

i switched the outside particels to visible for testing reason and they work. but when they enter the region they become invisble.....

i do not understand it ??

any ideas ??

greets
stucki

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: check wether an entity is in a region or not
« Reply #7 on: March 31, 2006, 01:39:14 PM »

ok got it by myself ....
the problem was the position of the region in the layers.
it was under some other pngs so they could not be seen ....

hurray its working now ...

thank you very much
 

Page created in 0.043 seconds with 24 queries.