id via call script [Resolved]

Started by Memor-X, November 28, 2010, 07:13:30 pm

Previous topic - Next topic

Memor-X

November 28, 2010, 07:13:30 pm Last Edit: November 29, 2010, 07:05:35 pm by Memor-X
is there a way to store the id of the event using the call script, like using

num = this.id


i need to know for my game as since i'm using Blizz-ABS, ABSEAL is messing with one of my maps, i can't disable it for the map cause there's over 50 enemies (plus other events such as objects, battle possessing) on it so i found a way to work around it, i have each enemy is actually a normal event with /eal in it's name with the first page being a parallel process which uses the rename event call script to rename the event into an enemy (removing the /eal also), after that it switches a local switch to true and the 2nd page which has the sprite and death event action takes over, it's so far worked for one enemy but like i said there's over 50 enemies on the map and there will be more maps like this and it'll be simpler and easier to manage if i could call upon the event's id in a cal script (cause if i use a variable but that's 50 events using the same variable storing their own event id and that will screw up or i could use 50 variables but that takes far more work than my current problem)

ForeverZer0


class Game_Map

  attr_accessor: event_ids

  alias stored_ids_setup setup
  def setup(map_id)
    @stored_ids = []
    stored_ids_setup(map_id)
  end
end

class Interpreter

  def store_id
    unless $game_map.stored_ids.include?(@event.id)
      $game_map.stored_ids.push(@event.id)
    end
  end
end


In a script call, simply put:
store_id


This will add this events ID to an array, which can be referenced with $game_map.stored_ids

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Memor-X

Quote from: ForeverZer0 on November 28, 2010, 07:49:10 pm

class Game_Map

  attr_accessor: event_ids

  alias stored_ids_setup setup
  def setup(map_id)
    @stored_ids = []
    stored_ids_setup(map_id)
  end
end

class Interpreter

  def store_id
    unless $game_map.stored_ids.include?(@event.id)
      $game_map.stored_ids.push(@event.id)
    end
  end
end


In a script call, simply put:
store_id


This will add this events ID to an array, which can be referenced with $game_map.stored_ids


ok, but then how do i get the id back dynamically without having to change every event cause if it's getting stored in an array, that means each id is then associated with an position in the array so i would be using something like

store_id
num = $game_map.stored_ids[#]


where # is the position of the array and if this is the case, it's just adding a line that i don't need, this is what i have at the moment

id = 23
b1 = '\\e[8] \\g[5]
$game_map.rename_event(id,b1)


if i was to add what i have above it'll turn out to

store_id
id = $game_map.stored_ids[#]
b1 = '\\e[8] \\g[5]
$game_map.rename_event(id,b1)


plus how would i know what # is anyway?

ForeverZer0

November 28, 2010, 08:39:45 pm #3 Last Edit: November 28, 2010, 08:41:55 pm by ForeverZer0
If you just want a way of getting the idea for that moment, and don't care about storing them, try this:


class Interpreter

 def get_id
   return @event.id
 end
end


You can get the index in the array if you need to this way:
index = $game_map.stored_ids.index(ID)

That will return the index in the array where that value is, though I don't think this what you need.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Aqua

November 28, 2010, 09:00:37 pm #4 Last Edit: November 28, 2010, 09:03:19 pm by Aqua
Can you use self.id? o-o

Memor-X

@ForeverZer0
Quote from: ForeverZer0 on November 28, 2010, 08:39:45 pm
If you just want a way of getting the idea for that moment, and don't care about storing them, try this:


class Interpreter

 def get_id
   return @event.id
 end
end



i tried it, it kinda worked, thing is that it did the wrong event, it changed one of the events i use like the pot from Legend of Zelda (so when you destroy it it drops health) and transformed it into the enemy, i have now

id = get_id
b1 = '\\e[8] \\g[5]
$game_map.rename_event(id,b1)


if it worked to how i wanted it to work, id should equal to 23 which is the id of the event i'm changing the name of, but the event that actually change i think was either 4 or 14 (i was just running up to the map to see where the enemy is supposed to be to see if it worked then i saw a rock moving with a health bar, the one 2 rocks in that aprox place is the ones with the ids of 4 and 14), any ideas

@Aqua: nope, tried that, didn't rename the event cause it had no health bar (it should if it worked

Blizzard

In a script call within an event, you can use @event_id directly. The script call is evaluated within the Interpreter class so it gives you access to all of its instance variables.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Aqua

Ah I knew it had something to do with referencing itself XD

Memor-X

Quote from: Blizzard on November 29, 2010, 02:14:43 am
In a script call within an event, you can use @event_id directly. The script call is evaluated within the Interpreter class so it gives you access to all of its instance variables.


yep, that worked, thanks, this will make things so much easier on the map and others like it, thanks for your help