A code help...
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
A code help...
Hi mates,
I want to mod a bit the autopilot vanilla functionality and needs just one "simple" thing: Make the skunk really exit the highways when it arrives at a zone destination even if that point dont have a exit gate (i mean in any point of a highway). I alreday have all mod code (xml/lua) ready but cant find just this - a way to simulate the key press (probably in lua).
Player can do this easily by pressing "backspace".... So, any idea on how to simulate a key press into the code?
Thanks for any advice!
I want to mod a bit the autopilot vanilla functionality and needs just one "simple" thing: Make the skunk really exit the highways when it arrives at a zone destination even if that point dont have a exit gate (i mean in any point of a highway). I alreday have all mod code (xml/lua) ready but cant find just this - a way to simulate the key press (probably in lua).
Player can do this easily by pressing "backspace".... So, any idea on how to simulate a key press into the code?
Thanks for any advice!
-
- Posts: 2963
- Joined: Tue, 18. Nov 14, 16:23
Hey Rubini! Long time no see. Hope you and the family have been well.
About your question, i don't think it's currently possible to bind keypresses to script actions. It's very possible though that there is a way but i just haven't found it yet.
However, if you're working with md, you could listen for events that result from certain actions. For example, a cue listening for event_autopilot_target_set would fire when autopilot is activated (if the documentation is correct). You probably already knew that though, so i suspect that you're looking for something else.
edit: sorry, just read your message again and finally understood that you want a script to fire a command as if a key were pressed rather than listening for a keypress. There are things like set_playership_throttle, but not sure if that's what you're after.
About your question, i don't think it's currently possible to bind keypresses to script actions. It's very possible though that there is a way but i just haven't found it yet.
However, if you're working with md, you could listen for events that result from certain actions. For example, a cue listening for event_autopilot_target_set would fire when autopilot is activated (if the documentation is correct). You probably already knew that though, so i suspect that you're looking for something else.
edit: sorry, just read your message again and finally understood that you want a script to fire a command as if a key were pressed rather than listening for a keypress. There are things like set_playership_throttle, but not sure if that's what you're after.
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Hi w.evans,w.evans wrote:Hey Rubini! Long time no see. Hope you and the family have been well.
About your question, i don't think it's currently possible to bind keypresses to script actions. It's very possible though that there is a way but i just haven't found it yet.
However, if you're working with md, you could listen for events that result from certain actions. For example, a cue listening for event_autopilot_target_set would fire when autopilot is activated (if the documentation is correct). You probably already knew that though, so i suspect that you're looking for something else.
edit: sorry, just read your message again and finally understood that you want a script to fire a command as if a key were pressed rather than listening for a keypress. There are things like set_playership_throttle, but not sure if that's what you're after.
All is ok, thanks, and you?
So much hard work in RL so just few free time to mod but I continue to support CWIR with BlackRain.
And yes, I know that isnt possible to bind a key press to script actions, but as you understood is not this what i want.
I just want to achieve a code - and probably this needs to be made in lua - (or at least knows if it is possible to do it) to simulate an already in game key press and in this case only Input_Action_Backspace will work for my needs.
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Just for info, i m trying a fix for this 4.00 issue posted here:
http://forum.egosoft.com/viewtopic.php?t=387979
http://forum.egosoft.com/viewtopic.php?t=387979
-
- Posts: 2963
- Joined: Tue, 18. Nov 14, 16:23
I can't complain. The kids are doing fine. And the financial situation is getting better. Still a bit concerned that it might not get better enough fast enough to avert ruin, but if we play our cards right, we should just about manage to scrape by, after which we should be in the clear.
About your project, that is a hard fix. The guidance stuff is in the C++ code, and is not easy to fix such that it takes account of all possibilities. Doesn't mean that you shouldn't try, but yeah.
I guess one way to deal with it script-side could be to change the intermediate guidance objectives it locks on to. Don't know if it's even possible to do that with scripts without guidance being active in the context of a mission though.
There are commands like get_closest_highway_offset and the aforementioned set_playership_throttle that might be useful, and it might be possible to cobble together a sort of autopilot guidance system with those commands, but i don't know how well that would work.
Good luck!
About your project, that is a hard fix. The guidance stuff is in the C++ code, and is not easy to fix such that it takes account of all possibilities. Doesn't mean that you shouldn't try, but yeah.
I guess one way to deal with it script-side could be to change the intermediate guidance objectives it locks on to. Don't know if it's even possible to do that with scripts without guidance being active in the context of a mission though.
There are commands like get_closest_highway_offset and the aforementioned set_playership_throttle that might be useful, and it might be possible to cobble together a sort of autopilot guidance system with those commands, but i don't know how well that would work.
Good luck!
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
hehehe...i have not any intention to go that deep on the code, like mess with C++. Im convinced that is possible to fix or at least give a better behaviour for Autopilot into the game just using scripts and lua. If I find a way to simulate an already existing key press into the code will be enough (not need to create any new bind keypress).
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
didnt verify but are you sure this will work? AP doesnt work by simulating keypresses/mouse input, so your attempt should work out if you do it manually - and i think during AP controls are locked (including backspace), so even if you somehow manage to simulate a keypress it wouldnt work.. or am i mistaken and [Backspace] still works?
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Hi Unitrader!UniTrader wrote:didnt verify but are you sure this will work? AP doesnt work by simulating keypresses/mouse input, so your attempt should work out if you do it manually - and i think during AP controls are locked (including backspace), so even if you somehow manage to simulate a keypress it wouldnt work.. or am i mistaken and [Backspace] still works?
Thanks by the advice. Im awared about this. Like i said above i alreday have almost all the code done and it works. I mean, even during AP control, the scripts (md/lua/aiscripts) works normally and I can know things like the zone i am, can control the skunk speed, i can change guidance, I can stop AP control, etc. The unique real problem is how to order the ship to exit highways without the phisic press backspace or without skunk have reach a highway exit gate.
I mean, the main problem is if a destination zone is at middle highway (no highway exit gate at this zone). The AP is then desengaged by vanilla code but skunk continue into the highway until find a highway exit gate (what can be several zones ahead eventually).
So, I can know this exactly moment by code (when the skunk reach the zone destination) - and then i need to order the code to simulate "press" the backscape. Just this.
And i have not found any vanilla function that do this in scripts/lua, or am i missing something?
Edited1: and yes, Backsapce works normally when Skunk is in Ap mode. (vanilla)
Edited2: i already tried to stop the skunk, at this point. It really stop but dont leave the highway. Just do it if i press backspace.
Last edited by Rubini on Sat, 19. Mar 16, 21:25, edited 2 times in total.
-
- Posts: 2963
- Joined: Tue, 18. Nov 14, 16:23
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
ah, ok.. didnt knew you already researched that muchRubini wrote:....

did you try to move the Ship to a huge X/Y-Offset in the Tube and/or set speed to 0 twice (in the AP Script)? or simply a move_to $zone with an intterupt on Zone Change to exit the script? not sure about the first two, but the last one should force the Ship to exit the Tube
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
I alreday tried a lot of things about Skunk speed at this point, even a new move_to as you suggested but didnt worked. I have not tried to make a huge x/y offset into the tube, this works when you are controling skunk manually into the tube, so perhaps it could work. Any idea on how to make this (move to a huge x/y offset into the tube?) . I will also try to mess a bit more with speed again. Perhaps a negative a speed ? Hummm...UniTrader wrote:ah, ok.. didnt knew you already researched that muchRubini wrote:....
did you try to move the Ship to a huge X/Y-Offset in the Tube and/or set speed to 0 twice (in the AP Script)? or simply a move_to $zone with an intterupt on Zone Change to exit the script? not sure about the first two, but the last one should force the Ship to exit the Tube
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Tried again with negative speeds and dont work. Skunk almost stop but dont leaves the highway (even after the code disengage the AP because it already have reached its destination). Move_to also didnt work...
So, a move to a huge x/y offset into the tube is my last option. Any idea on how to do this inside the tube?
So, a move to a huge x/y offset into the tube is my last option. Any idea on how to do this inside the tube?