Jump to content
zarwil

Is it possible to activate the scripts of entities indirectly through an event listener?

Recommended Posts

I haven't spent much time with scripting on this game, but at the moment I'm scripting some cannon broadsides with visual effects (fire, smoke etc...). Currently I have a ship with working cannon fire in 4 directions as well as a range adjustment by tilting the cannons. This is all controlled by levers behind the ship's helm. The problem with this is that when piloting the ship by yourself you have to leave the helm in order to pull the levers, which is a bit cumbersome (ideally you would have a friend controlling the levers). 

What I'm trying to do at the moment is to script a ship duel game (something simple as a proof of concept). I want to tie the cannon fire and range adjustment to custom inputs on the keyboard, and here's where the trouble begins. I've successfully scripted custom user inputs while controlling the ship, I can make it change the time of day etc with an event listener tied to the custom user actions. I then tried to make the event listener activate the levers on the ship (which contain the scripts for the cannons), but this doesn't work. You can make the event listener pull the levers, but this does not activate their scripts, as I'm guessing the levers have to be pulled by a player for the scripts to work. 

Is the only way forward to remake the cannon fire scripts from scratch inside event listeners or can I do something more efficient? I really want to avoid redoing all the scripts.

Alternatively, is there a way of copying the scripts from entities and reusing in an event listener?

Share this post


Link to post
Share on other sites
Just now, Hunter-Over-Fire said:

Are the scripts in the levers set to "on interact?" or "on switch on/off?"

They're set to on switch on/off.

Share this post


Link to post
Share on other sites

Hello :) 
You can copy paste scripts simply with ctrl+c ctrl+v, just make sure to enclose them to some custom instruction, so you can select the whole thing at once. :) In this case it would be the best to simply call the fire and tilting methods straight from the listener for custom controls. :) 


Events like open/close and on/off are not triggered when called through script, because these are meant to be just for the case when someone actually interacts with them. ^^ 

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×