(ESP / ENG)
Hola a todos.
Quiero daros las gracias a todos por vuestra ayuda. Finalmente lo hice funcionar como deseaba.
Respecto a los temas propuestos, lo solucioné así:
1) CapBall:
Leí las rutinas de core.vbs, vbsdoc_outdated.html, y vi el código y los objetos en la mesa Theatre of Magic, y entendí el funcionamiento básico así:
Un kicker crea la bola cautiva y a la vez la impulsa. El Trigger exterior detecta la bola activa e inicia la rutina de rebote y lanzamiento, leyendo su velocidad de impacto. El muro intermedio mantiene la bola cautiva en su sitio y hace rebotar a la bola activa en juego. Y un trigger interno de la zona acotada desactiva y reactiva el kicker de rebote y lanzamiento (_Hit y _Unhit), cuando la bola cautiva sale o regresa al punto de partida.
Pero cuando declaraba objeto de clase, me daba Error line 1: necesita un controller.
Pensé que tenía problemas al cargar controller.vbs al inicio del Script, pero el error se mantenía. Al final, y tras descargar las ultimas versiones de los archivos core.vbs y controller.vbs (pensé que estaban obsoletos, y no era así) opté por hacer todo yo mismo desde cero, siguiendo el mismo esquema básico. Una especie de ingeniería inversa, que finalmente sí funciona.
Epe Solución:
En el editor creo un único kicker (KickerCap) para crear y lanzar la bola cautiva, a modo de kicker de rebote. He creado solo uno, aunque haya muchas bolas dentro del recinto. Esta es una diferencia importante con el modelo original, que asignaba un kicker para cada bola cautiva dentro de la zona acotada.
Luego creo en el editor un Trigger (TrigHit) para detectar el evento de colisión en la zona de impacto. Notaréis que usé nombres similares a los de las rutinas en el core.vbs.
Luego en el Script creo dos variables para almacenar los datos temporales relativos a la velocidad X/Y de la bola activa que impacte la zona del Trigger disparador de eventos de rebote (a la que más arriba me refería a ella como campo de fuerza).
En la Sub _Hit del evento de impacto, asigno a las variables auxiliares que controlan las velocidades X e Y y las paso como parámetros al kicker que se encarga de dar movimiento a la bola cautiva en reposo.
No he usado el segundo Trigger, el de dentro de la zona acotada, para reactivar el Kicker de rebote, ya que permanece activo todo el tiempo. Pero final mente lo usaré para esta finalidad y así dar cierta soltura a la bola rebotadora.
En el Script queda así:
'Define y crea la Captive Ball
KickerCap.CreateBall
KickerCap.kick 0,1
'Define variables auxiliares
Dim mVelX 'almacena velocidad de bola en juego
Dim mVelY 'almacena velocidad de bola en juego
'Rutina de activación de impacto en el Trigger TrigHit del campo de fuerza
Sub TrigHit_Hit
' Light002.State = 2
mVelX = ActiveBall.VelX 'define el ángulo de rebote
mVelY = 0 - ActiveBall.VelY 'Para dar velocidad en vertical hacia arriba VelY debe ser negativo respecto a la fuerza de gravedad positiva, para obtener el valor negativo la velocidad vertical se resta de cero
KickerCap.kick mVelX,mVelY 'lanza la Captive Ball con ángulo y velocidad
End Sub
NOTA: expandiendo o moviendo por la mesa el Trigger detector de colisión (e incluso creando otros varios) se puede hacer que se impacte a la bola cautiva desde varios sitios de la mesa, como si se diera contra un campo de fuerza que transmita la inercia.
Se me corre conectar los bumpers con la propiedad Nudge (salvando el Tilt!) para causar temblores en toda la mesa haciendo un poco más exagerado este efecto. XDD
Además el muro de retención se puede expandir o agregar otros invisibles a distintas escalas para que físicamente la bola activa en juego no llegue a la zona cercana de la bola cautiva. Esto me gusta para simular una especie de canalización mágica, Magia o Fuerza invisible que active el efecto de rebote para dar juego.
Gracias unclewilly. Me fue muy útil toda esa información que saqué de allí.
2) Teletransporte:
Gracias bigus1, por tu solución. No se me habría ocurrido mover la bola modificando sus corrdenadas en mesa. Me parece una solución muy elegante y eficaz. Además genera menos código en el Script y mucho menos procesamiento de datos, con lo cual es más fluida la mesa al jugar. De haber pensado en esta solución antes me habría ahorrado tener que utilizar kicker de entrada (que destruya bola), kicker de salida (que genere una nueva bola), además de todo el código que implica.
Finalmente sólo tuve que crear dos Triggers, uno de entrada (TriggerIn) y otro de salida (TriggerOut). Y en la subrutina _Hit de cada uno, colocar las coordenedas de la mesa donde debe aparecer la bola al atravesar dichos portales Trigger. El único detalle que hay que tener en cuenta es que al aparecer (mover) la bola al otro lado, no pise ni active el Trigger de retorno.
Este es mi código:
'Teletransporte de bolas
'En estas rutinas la Bola Activa se teletransporta a las coordenadas espaciales especificadas en la mesa
'si no se especifica velocidad con las propiedades VelX y VelY, la bola usará su misma inercia de llegada al TriggerIn_Hit
Sub TriggerIn_Hit() 'Trigger de Entrada
ActiveBall.X = 60
ActiveBall.Y = 1080
' ActiveBall.Z = 125
' ActiveBall.VelX = 0
' ActiveBall.VelY = 0
End Sub
Sub TriggerOut_Hit() 'Trigger de Salida y/o Retorno
ActiveBall.X = 902
' ActiveBall.Y = 1080
' ActiveBall.Z = 125
' ActiveBall.VelX = 0
' ActiveBall.VelY = 0
End Sub
Gracias Bigus1 por darme el código base, de ti he aprendido las coordenadas especiales de la bola activa en juego.
Gracias Unclewilly, tienes razón, es muy elegante y útil la solución de teletransportar la bola modificando sus coordenadas espaciales sobre la mesa, además apenas consume procesamiento de datos y la mesa se vuelve mucho más fluida que controlando un montón de artilugios y sus subrutinas anejas.
Gracias a todos por vuestra colaboración.
Recibid un cordial saludo.
EpeC.
----
Hello everyone.
I want to thank you all for your help. I finally got it working the way I wanted.
Regarding the proposed topics, I solved it like this:
1) CapBall:
I read the core.vbs routines, vbsdoc_outdated.html, and saw the code and objects on the Theater of Magic table, and understood the basic operation like this:
A kicker creates the captive ball and at the same time propels it. The external Trigger detects the active ball and starts the bounce and launch routine, reading its impact speed. The intermediate wall keeps the captive ball in place and bounces the active ball in play. And an internal trigger in the bounded area deactivates and reactivates the rebound and launch kicker (_Hit and _Unhit), when the captive ball leaves or returns to the starting point.
But when I declared class object, it gave me Error line 1: needs a controller.
I thought I was having problems loading controller.vbs at the start of the Script, but the error remained. In the end, and after downloading the latest versions of the core.vbs and controller.vbs files (I thought they were obsolete, and they were not) I chose to do everything myself from scratch, following the same basic scheme. A kind of reverse engineering, which finally works.
Epe Solution:
In the editor I create a single kicker (KickerCap) to create and launch the captive ball, as a rebound kicker. I have created only one, even though there are many balls inside the enclosure. This is an important difference from the original model, which assigned a kicker for each captive ball within the bounded zone.
Then I create a Trigger (TrigHit) in the editor to detect the collision event in the impact zone. You'll notice that I used names similar to those of the routines in core.vbs.
Then in the Script I create two variables to store the temporary data related to the X/Y speed of the active ball that impacts the Trigger zone that triggers rebound events (which I referred to above as a force field).
In the Sub _Hit of the impact event, I assign the auxiliary variables that control the X and Y velocities and pass them as parameters to the kicker, which is responsible for giving movement to the captive ball at rest.
I have not used the second Trigger, the one inside the bounded area, to reactivate the Rebound Kicker, since it remains active all the time. But finally I will use it for this purpose and thus give some looseness to the bouncing ball.
In the script it looks like this:
'Define and create the Captive Ball
KickerCap.CreateBall
KickerCap.kick 0.1
'Defines auxiliary variables
Dim mVelX 'stores ball speed in play
Dim mVelY 'stores ball speed in play
'Impact activation routine in the Force Field Trigger TrigHit
Sub TrigHit_Hit
' Light002.State = 2
mVelX = ActiveBall.VelX 'defines the bounce angle
mVelY = 0 - ActiveBall.VelY 'To give velocity vertically upwards VelY must be negative with respect to the positive force of gravity, to obtain the negative value the vertical velocity is subtracted from zero
KickerCap.kick mVelX,mVelY 'launches the Captive Ball with angle and speed
End Sub
NOTE: by expanding or moving the collision detection trigger around the table (and even creating several others) you can impact the captive ball from various places on the table, as if it were hitting a force field that transmits inertia. .
I run into connecting the bumpers with the Nudge property (saving the Tilt!) to cause tremors throughout the table, making this effect a little more exaggerated. XDD
In addition, the retaining wall can be expanded or other invisible ones added at different scales so that physically the active ball in play does not reach the nearby area of the captive ball. I like this to simulate a kind of magical channeling, Magic or Invisible Force that activates the rebound effect to give play.
Thanks unclewilly. All that information I got from there was very useful to me.
2) Teleportation:
Thanks bigus1, for your solution. It would not have occurred to me to move the ball by modifying its coordinates on the table. I find it a very elegant and effective solution. It also generates less code in the Script and much less data processing, making the table more fluid when playing. If I had thought about this solution before, I would have saved myself from having to use input kicker (which destroys ball), output kicker (which generates a new ball), in addition to all the code that entails.
Finally I only had to create two Triggers, one for input (TriggerIn) and one for output (TriggerOut). And in the _Hit subroutine of each one, place the coordinates of the table where the ball should appear when passing through said Trigger portals. The only detail to keep in mind is that when the ball appears (moves) to the other side, do not step on or activate the Return Trigger.
This is my code:
'Ball teleportation
'In these routines the Active Ball is teleported to the spatial coordinates specified on the table
'if speed is not specified with the VelX and VelY properties, the ball will use the same arrival inertia at TriggerIn_Hit
Sub TriggerIn_Hit() 'Input Trigger
ActiveBall.X = 60
ActiveBall.Y = 1080
' ActiveBall.Z = 125
' ActiveBall.VelX = 0
' ActiveBall.SpeedY = 0
End Sub
Sub TriggerOut_Hit() 'Output and/or Return Trigger
ActiveBall.X = 902
' ActiveBall.Y = 1080
' ActiveBall.Z = 125
' ActiveBall.VelX = 0
' ActiveBall.SpeedY = 0
End Sub
Thank you Bigus1 for giving me the base code, from you I have learned the special coordinates of the active ball in play.
Thanks Unclewilly, you are right, the solution of teleporting the ball by modifying its spatial coordinates on the table is very elegant and useful, it also barely consumes data processing and the table becomes much more fluid than controlling a bunch of gadgets and their attached subroutines.
Thank you all for your collaboration.
Receive a cordial greeting.
EpeC.
Edited by EpeCreaciones, 27 April 2024 - 04:31 AM.