Page 1 of 1
Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:10 am
by Isaac
I'd like to know if a script can fake a key-press (that the engine reacts to), or to call a function that causes the party to move; as though the player had pressed a key.
If there is no such method, I'd really like for
that to be in the next patch (if one is planned).
I'm tackling the first spinner trap in EoB; the one with the cursed sling, that rotates the party if they step on it.
I planned to use teleporters that change the party facing, but I thought it would be a nice touch if the party view actually showed the spin take place.

Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:20 am
by Brodie301
Do you remember the one spinner from the Main game on level 9?
You see the walls and compass change. I have one in my mod as well.
When you say see the spin take place are you talking about an animation or kind of change facing twice?
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:22 am
by Isaac
I was thinking it would be neat to have the engine trigger a right or left turn via script.
**I mistook one of the teleporter functions for being able to change facing, but... nope it's not for that.
Edit: I don't actually remember that spinner trap on level 9 ~offhand.
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:48 am
by Brodie301
It's between the armory and door where ice lizards start.
I didn't script mine just used the editor.
I used 3 spaces, 1 teleporter that is activated triggered by party change facing invisible and silent, then 2 hidden pressure plates on each side of it one that is activate teleporter activate and one that is activate teleporter deactivate.
When you hit first plate it leaves teleporter on you the hit teleporter which goes to next block but facing changed and deactivates the teleporter so you are walking back thru it to the other plate which activates it again.
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:58 am
by Isaac
Edit: There was a bug in this code but it did expose a repeatable editor crash.I just stumbled upon the solution (or so I thought); the target of a teleporter can be set via script and it accepts a choice of facing.
However... This works for me (as I had expected); it changes the party facing, but then promptly crashes the editor.

function spinner()
x = math.random(4)
<< Bug
spinnerTrap:setTeleportTarget(19, 27, x, 2)
end
Setup:
One script object [with the above code]
One hidden pressure plate [connected to the script @ 19,27]
One teleporter [named spinnerTrap]
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:59 am
by Neikun
Maybe with a timer you could have it activate multiple teleporters in sequence. Deactivate the timer with a counter perhaps?
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 3:07 am
by Isaac
Neikun wrote:Maybe with a timer you could have it activate multiple teleporters in sequence. Deactivate the timer with a counter perhaps?
I thought about it; but I tried the above; it works very well except for the side effect.
I hope I'm doing something wrong, and that I can use this method correctly/safely; it's perfect.
I'm thinking that I might need to script a deactivate function, as the teleporter points to itself.
Update: Solved; (no more crashes).
Code: Select all
function spinner()
x = (math.random(4)-1)
spinnerTrap:setTeleportTarget(19, 27, x, 2)
end
I noticed that it only crashed when the numbers directed it north. It was passing a '4' instead of a zero.
Still no turning animation, but it's accurate to EoB.

Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 7:17 am
by petri
I think this is a good idea. Added to the list.
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 8:53 am
by djoldgames
@isaac:
FOr the EOB mod I have scripts called party_rotators. This is the source:
Code: Select all
onMove = function(self,dir)
for e in help.entitiesAtDir(self,dir) do
if e.name == 'teleporter_rotator90' then
e:setTeleportTarget(e.x, e.y, (self.facing + 1)%4)
print("Party rotated by 90")
end
if e.name == 'teleporter_rotator180' then
e:setTeleportTarget(e.x, e.y, (self.facing + 2)%4)
print("Party rotated by 180")
end
if e.name == 'teleporter_rotator270' then
e:setTeleportTarget(e.x, e.y, (self.facing + 3)%4)
print("Party rotated by 270")
end
end
end
This is for party.onMove hook. Only one thing you must to do is clone telepporter as new instance named "teleporter_rotator90" etc. and place it anywhere using the editor without additionaly scripting. There is also many places in EOB where teleporter target is out of teleporter x,y then you can free change teleporter target by editor.
You don't need to deactivate teleporter_rotator, if party is in One teleporter, trigger is activated only once.
Check my
EOB thread, I upload my "cleaned" souce code soon...
Re: Is it possible to script party movement?
Posted: Tue Oct 16, 2012 2:05 pm
by Isaac
petri wrote:I think this is a good idea. Added to the list.
djoldgames wrote:Check my
EOB thread, I upload my "cleaned" souce code soon...
Very sharp [and elegant] solution.
