Script Call Equivalent of Events

Ahh perfect. Thank you for that. Im going to do some more digging in the Game_Interpreter then because Ace has a very powerful eventing system and i can probably get some good info. I have a keen interest in scripting and am looking ti learn more about it. Mine as well start with some existing calls. Ty again :]
While not quite a script equivalent, it does allow you to more easily access game switches by using their name instead of only their id:

# Code by Filip H.F. "FiXato" Slagter# Place this under Materials and above Main Process and before any scripts that would make use of it.# Allows you to also use Game Switch *names* instead of just IDs in $game_switches[] calls.class Game_Switches # Overload the [] method so we can also call switches by their name, for instance: # $game_switches['my switch'] alias_method :find_by_name, :[] def [](switch) switch_id = (switch.kind_of?(String) ? $data_system.switches.find_index(switch) : switch) find_by_name(switch_id) end # Overload the []= method so we can also set switches by their name, for instance # $game_switches['my switch'] = true alias_method :set_by_name, :[]= def []=(switch,value) switch_id = (switch.kind_of?(String) ? $data_system.switches.find_index(switch) : switch) set_by_name(switch_id, value) endendThis allows you to easily find one of your game switches by name, instead of knowing their ID.

I use this in my upcoming Sleepable Regions script to auto-enable a Common Event if the user names the condition switch for its parallel process "Sleepable Regions".

And two more:

  • Recover All for your entire party😠params = [0, 0]command_314
  • Show a named animation (in this case 'Sleep') for the player and wait for it to end:

    Code:
    animation_name = 'Sleep'animation_id = $data_animations.find_index{|ani|ani && ani.name == animation_name}@params = [-1, animation_id, true]command_212

Interesting idea, but it opens you right up to typos and case issues.
As for typos, I guess. Though you can also mistype an ID. With regards to case-mismatches: I can add a downcase to it tomorrow so it becomes case-insensitive. 🙂
Posted a question over in the ace community and was directed here. I've looked over every page and don't see quite what I'm looking for... so I guess I'll post it.

Here's what I'm doing:

I have six colored posts. In a rectangular (2x3) formation with one space in between. 

There are two switches. When you hit the left switch, the four posts on the left rotate counter clockwise. When you hit the right switch, the right four rotate clockwise. 

(They share the middle two posts.)

I'm wondering if there is a Script Call that will call: "Event at Coordinates (x,y)"

Since the Events will be changing locations, I can't just use the ID for movement but need to say Whichever Post is Here move two spaces left, etc...
[...]

I'm wondering if there is a Script Call that will call: "Event at Coordinates (x,y)"

Since the Events will be changing locations, I can't just use the ID for movement but need to say Whichever Post is Here move two spaces left, etc...
I think you need $game_map.events_xy(x, y) or $game_map.tile_events_xy(x, y) for that, which will return an array of (Tile-handling) events at those coordinates.

Have a look at the source of Game_Map in the Script Editor for similar methods
This thread is for script calls of existing event commands. Event at Coordinates(x,y) is not an existing event command. It's okay to post a new thread for your very specific question, instead of trying to find an existing one to add them to 🙂
i want to check the position of Player and compare with the position at side of Events

Variable [6] = Position X Player
Variable [7] = Position Y Player

Variable [8] = Position X Event
Variable [9] = Position Y Event

[IMG]http://i.imgur.com/o2pWQN6.png[/IMG]

if the player is in the first o third position the event start, using this condition only start in the third, anyona can help me?
 

(($game_variables[8] += 1 or $game_variables[8] -= 1) == $game_variables[6]) and ($game_variables[9] == $game_variables[7])EDIT: If anyone knows a better way to do this please tell me
+= is changing the value of the variable. You don't want to do this.


You only want to see if the player is standing beside the event? Or on any one of the 4 numbered tiles?


If you only want them to be beside the event (positions 1 or 3), use this:

$game_variables[7] == $game_variables[9] and ($game_variables[6] - $game_variables[8]).abs == 1(which says if the y value is the same and there is a difference of 1 between the x values
If you want them to be on any of the 4 numbered tiles, use this:

Code:
($game_variables[6] - $game_variables[8]).abs + ($game_variables[7] - $game_variables[9]).abs == 1
(which says there is a difference of 1 between the x values OR a difference of 1 between the y values
Thanks works perfectly but i cant understand the condition, can explain me better?

($game_variables[6] - $game_variables[8]).abs + ($game_variables[7] - $game_variables[9]).abs == 1variable 6 deduct variable 8.... what is .abs? 

+ means "and" ?

.abs == 1? the first .abs takes value of 1 because is asigned here?
.abs means the absolute value.
Sorry i read again the formula

($game_variables[6] - $game_variables[8]).abs  

+

($game_variables[7] - $game_variables[9]).abs

== 1

IF first formula added to second formula  are 1, trigger the event, the .abs is for negative result, thnx again
($game_variables[6] - $game_variables[8]).abs + ($game_variables[7] - $game_variables[9]).abs == 1


It is comparing the difference between the x position of the player and the tile of interest. Using abs lets me take one away from the other in any order and still end up with a positive number - it doesn't matter which has the higher or lower x value. Then it does the same with the y position of the player and the tile of interest. Then it adds them together (+ means plus, not and). So if the sum of the x distance and the y distance between the two tiles is 1, it means the player is on a tile that is directly touching the tile of interest (and not corner-ways, as then the sum of the numbers would be 2)


Also, please take more care with where you post your questions. If you read the initial post in this thread, you would see that this thread is for the script equivalents of individual event commands, not for "how do I do ... using scripts and variables". Basically, if you can't do it with a single event command, it doesn't go here - you should start a new thread or look for somewhere more suitable.
Note that you don't need to use the game variables to get the current x and y position of the player:

$game_player.x$game_player.yare the script equivalents of the player's current coordinates. 🙂
Similarly,

Code:
$game_map.events[id].x$game_map.events[id].y
give you the event's coordinates in script, without having to use variables. Event id should not have leading zeros - so EV006 would just be written as [6]
im back 😛

I have troubles with a script calls


$game_player.followers = true or false

This come to error "undefined method Followers= "
Not sure why you are doing that, but if you're trying to hide followers (and for whatever reason you can't just use the event command that does this)

$game_player.followers.visible = falseI would just use the event command. It is an additional layer of abstraction that allows scripters to add additional behavior on top of what the command usually does.Using script calls simply means you are limiting yourself from possible new features.
Not sure why you are doing that, but if you're trying to hide followers (and for whatever reason you can't just use the event command that does this)

$game_player.followers.visible = falseI would just use the event command. It is an additional layer of abstraction that allows scripters to add additional behavior on top of what the command usually does.Using script calls simply means you are limiting yourself from possible new features.

I'm compiling the script calls in this topic to do a list and...im bored so i do something😛
idk if this is relevent, but how would one force a button press? i know how to check if a button is being pressed but how would you force a button press?
Can't you just call whatever would be called if the button were pressed?


I believe forcing a button press would require some Windows APIs to be called.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-equivalent-of-events.6248/