Beschreibung : Das Script zeigt in Areas mit speziellen namen die ihr einstellen könnt ein von euch eingestelltes emote, somit kann zb ein ausrufezeichen automatisch angezeigt werden wenn ein item in der nähe ist
Anmerkung :
Danke an Tally für Idee und Betatesting
Demo v1.2
http://rapidshare.com/files/112128206/MapMarker.rar (http://rapidshare.com/files/112128206/MapMarker.rar)
Anleitung :
#==============================================================================
# F.A.Q.
#==============================================================================
# Benutzt das MARKER-Array um eure Area-Namen einzustellen und die Balloon ID
# für das Emote das ihr haben möchtet. Ihr könnt soviele Zeilen hinzufügen wie ihr
# wollt
#
# Auf der Karte braucht ihr dann nur ein Area zu erstellen mit einem der Namen
# die ihr zuvor eingestellt habt und das emote wird automatisch angezeigt
#
# Um die markierung vom letzten Area zu löschen das ihr betreten habt,
# erstellt ein call script mit diesem darin :
# $game_player.delete_mark
#==============================================================================
# Main config
#==============================================================================
MARKER = [ ["item 1",1], # [Areaname,Balloon ID]
["item 2",2], # Example 1
["item 3",3], # Example 2
["item 4",4], # Example 3
]
Script v1.2
#==============================================================================
# Map Marker
#
# Version : 1.2 - 01.04.08
# Created by : hellMinor
# Do NOT redistribute without my permission
# Description : A little script to show a Emote Icon if you enter an
# area with specific name
#
#==============================================================================
# F.A.Q.
#==============================================================================
# Use the MARKER-Array to define the Area names and the Balloon ID for the
# emote which should be shown in it. You can add as much lines as you want.
#
# On the map, just make an area with one of the names which you defined and
# the emote will be shown automatically
#
# To delete the mark of the last area you entered just make a call script
# with this in it : $game_player.delete_mark
#==============================================================================
# Main config
#==============================================================================
MARKER = [ ["item 1",1], # [Areaname,Balloon ID]
["item 2",2], # Example 1
["item 3",3], # Example 2
["item 4",4], # Example 3
]
#==============================================================================
class Game_Player < Game_Character
#==============================================================================
def in_item_area?(area)
return false if area == nil
return false if $game_map.map_id != area.map_id
return false if @x < area.rect.x
return false if @y < area.rect.y
return false if @x >= area.rect.x + area.rect.width
return false if @y >= area.rect.y + area.rect.height
for i in 0..MARKER.size-1
if area.name == MARKER[i][0]
@last_area = area.id
@mark = MARKER[i][1]
return true
end
end
return false
end
#------------------------------------------------------------------------------
def auto_exclamation
for area in $data_areas.values
$game_player.balloon_id = @mark if in_item_area?(area)
end
end
#------------------------------------------------------------------------------
def delete_mark
for area in $data_areas.values
area.name = "mark deleted" if area.id == @last_area
end
end
#------------------------------------------------------------------------------
alias update_nonmoving_auto_exclamation update_nonmoving
def update_nonmoving(last_moving)
update_nonmoving_auto_exclamation(last_moving)
auto_exclamation if last_moving
end
end
I agree, Erzengel. Everyone should write script in the way they like :)
However, I tried that script in http://tryruby.hobix.com/ (http://tryruby.hobix.com/), and this is what I got.
>> Array = [0,1,2,3,4,5]
=> [0, 1, 2, 3, 4, 5]
>> for i in 0..Array.size
>> p i
>> end
0
1
2
3
4
5
6
=> 0..6
You will see that there's 6 in there too, and Array[6] will return nil because there's no value in that index.
Therefore,
for i in 0...MARKER.size
will not work.
>> Marker = [ ['item 1', 1],
>> ['item 2', 2],
>> ['item 3', 3],
>> ['item 4', 4],
>> ]
Using Marker.size, it gives no MethodError
>> for i in 0..Marker.size
>> if 'item 5' == Marker[i][0]
>> p 'found!' + i.to_s
>> end
>> end
NoMethodError: undefined method `[]' for nil:NilClass
from (irb):11
from (irb):10:in `each'
from (irb):10
Marker.size-1 will work fine.
>> for i in 0..Marker.size-1
>> if 'item 5' == Marker[i][0]
>> p' found!' + i.to_s
>> end
>> end
=> 0..3
Don't worry, we still have many things we have to learn in Ruby (or RGSS :P).
I'm sure you also knew something that I don't know. :)
@Hellminor
I mean by the script in Erzengel's post~
EDIT:
Save space :3~