Sorry for the indescriptive title, but I don't think if I'd written 'Beacon Script problems', you wouldn't been informed better ^_^
Anyway, I tried to make a Beacon script... and as it's the first time somebody attempts this (AFAIK), I'll explain it's purpose shortly:
Events on the map marked with a 'Beacon' comment have an opacity of 0 until the player comes near them. Depending on how close the main character gets, the opacity raises and becomes 255 if the player is above the object. If he gets further away, the opacity decreases again. Of course, this should work with multiple objects on a map simultaneously.
Well, that's the theory... my tries to get this thing to work ended like this:
This is the first version which doesn't brings up any errors, but the events simply don't care about the script ^_^. I commented the 'action' lines for you guys so you can see what I was trying to do, but I have no clue how to go on from here... help would be very apprechiated... :D
Thanks in advance
Anyway, I tried to make a Beacon script... and as it's the first time somebody attempts this (AFAIK), I'll explain it's purpose shortly:
Events on the map marked with a 'Beacon' comment have an opacity of 0 until the player comes near them. Depending on how close the main character gets, the opacity raises and becomes 255 if the player is above the object. If he gets further away, the opacity decreases again. Of course, this should work with multiple objects on a map simultaneously.
Well, that's the theory... my tries to get this thing to work ended like this:
PHP:
class Beacon
#--------------------------------------------------------------------------
attr_accessor :character
#--------------------------------------------------------------------------
def initialize(character=nil)
@character = character
end
#--------------------------------------------------------------------------
def main
# checks for the comments inside the event
if (character.is_a?(Game_Event) and character.list!=nil and
character.list[0].code == 108 and
character.list[0].parameters == ["Beacon"])
# checks for distance between player and event
d=Math.sqrt(dx.abs**2+dy.abs**2)
# changes the event's opacity relative to the distance
character.opacity = [255-d*80,0].max
end
end
#--------------------------------------------------------------------------
end
This is the first version which doesn't brings up any errors, but the events simply don't care about the script ^_^. I commented the 'action' lines for you guys so you can see what I was trying to do, but I have no clue how to go on from here... help would be very apprechiated... :D
Thanks in advance