Ship rotation mod idea.

A place to discuss mods in development and concepts for new mods.
marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Sat Feb 27, 2016 1:42 am

Okay, I just re-uploaded it to xelerus with some code to give it a little more incremental rotation.

If your aim is already close to the target, it looks pretty good.

If you are not close, it has a tendency to make a longer clockwise rotation back around to the target - I suppose this is what you get if you are not making an attempt to aim it yourself.

I made a half-move event - where it should be rotating to the halfway point between its current direction and the target at each of 5 pre-timed events: (so it works even if the ship is still moving - though you are better off stopping the ship before the 30th tick so you don't lose the target).

added this to oncreate:

(sysAddObjTimerEvent 5 gSource 'halfmove)
(sysAddObjTimerEvent 10 gSource 'halfmove)
(sysAddObjTimerEvent 15 gSource 'halfmove)
(sysAddObjTimerEvent 20 gSource 'halfmove)
(sysAddObjTimerEvent 25 gSource 'halfmove)


added this half-move event/code:

("now" is the ship's current angle; "want" is the angle where it will be when it is facing the target on tick 30, and "desire" is the halfway point between the two angles).


<Halfmove>
(block (now want desire)
(setq now (objGetProperty gplayership 'rotation))
(setq want
(sysCalcFireSolution (sysVectorSubtract (objGetPos (objGetTarget gPlayerShip)) (objGetPos gPlayerShip)) (sysVectorSubtract (objGetVel (objGetTarget gPlayerShip)) (objGetVel gPlayerShip)) (typGetDataField (itmGetType (objGetProperty gPlayerShip 'selectedWeapon)) "speed")))
(gr (abs (subtract now want)) 180)
(setq desire (add (divide (add (subtract now 360) want) 2) want))
(leq (abs (subtract now want)) 180)
(setq desire (add (divide (subtract now want) 2) want))
(objSetProperty gplayership 'rotation desire)
)
</Halfmove>


Don't be too harsh - I have no idea what I am really doing - just glad it kind of works.

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Sat Feb 27, 2016 2:58 pm

I've been using Notepad++ to do multi-file searches to see how other people have used those functions so I can learn based on context.
gunship256, thanks for that tip! I just tried this - and it turns out jedit can do this too!

Wow!

This will be a real time saver!

relanat
Militia Commander
Militia Commander
Posts: 328
Joined: Tue Nov 05, 2013 9:56 am

Re: Ship rotation mod idea.

Post by relanat » Thu Mar 03, 2016 5:07 am

gunship256 wrote:What about a slotless device that would make your ship turn to face whatever target is selected? It could have an invoke key to prevent having to go through a dockscreen.
Yes. I lke this idea and will probably do it but will stick to the dockscreen for now because I know how to use them. I've only just found out what you meant by 'Invoke' (<Invoke key="X">.....</Invoke>). I saw a couple of examples in the Excalibur Targeting ROM mod. Before that I thought it had something to do with pressing 'I' and Domina powers!

=====================
I've found a couple of ways to rotate the ship using loop but they all happen too quickly. Is there not some way to feed 'left arrow' or 'right arrow' commands to the game? Or data of this type? This would take out the need to define the ship rotation speed for different ships beause the arrow keys already do this.

Or, new idea, it could be possible to press a key to set a limit to how far a ship would turn. Say press 'X" and you could turn the ship with the arrow keys until it pointed to a cardinal point and then it would automatically stop. That would line you up. Then the arrow keys resume normal function unless you press 'X' again. Same result, you're pointing where you want, but much less fiddling.

====================
Have added a messy updated version which doesn't need the second dockscreen.
Now just point the ship within 45 degrees of the cardinal point you want, press 'S', and then press 'P'oint. The ship instantly points in the desired direction.
There are a couple of code examples doing this in different ways. One theoretically turns the ship degree by degree but the code runs so fast it's virtually instant.

===================
Nice work, marsrocks. The odd longer clockwise rotation is because Trans uses East as 0 and 360. When the ship is reducing its rotation angle its doing it from 360 even though the other way is shorter; and other silly behaviour might be because its changing the 'now' angle as the ship goes past 360 and then automatically converts this value to 0. Try putting a dbgOutput in there somewhere to see what the 'now' value is doing. Especially if you are SE of the target. I'm having to sort this out too.

E is 0 and 360
N is 90
W is 180
S is 270

And the Santa Box is excellent. Very useful. Wish I'd known about it before.

And I love your quote; "I have no idea what I am really doing - just glad it kind of works." If I knew how to put one of those signature line thingys in I'd put that there. Sums up modding really!

======================
And completely off topic, 1.7 has a file called RPGShipBroker.xml. Yippee.
Attachments
AutoShipPointing.xml
(6.53 KiB) Downloaded 13 times

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 09, 2016 3:27 pm

relanat,

Thanks. You've inspired me to try again - this time making a new device called "Target Lock."

I've worked out the smooth turning with this code below added to a virtual ship created by the device:



<OnCreate>
(block Nil

(sysAddObjTimerEvent 2 gSource 'CounterMove)

; (sysAddObjTimerEvent 2 gSource 'ClockMove)

(sysAddObjTimerEvent (random 100 200) gSource 'Disappear)
)
</OnCreate>

<Disappear>
(objDestroy gSource)
</Disappear>



<Targetnow>
(block Nil
(setq angle
(sysCalcFireSolution (sysVectorSubtract (objGetPos (objGetTarget gPlayerShip)) (objGetPos gPlayerShip)) (sysVectorSubtract (objGetVel (objGetTarget gPlayerShip)) (objGetVel gPlayerShip)) (typGetDataField (itmGetType (objGetProperty gPlayerShip 'selectedWeapon)) "speed")))
(objSetProperty gplayership 'rotation angle)

(plyMessage gPlayer "Locked on target.")
)
</Targetnow>




<ClockMove>
(block (now want)
(setq now (objGetProperty gplayership 'rotation))
(setq want
(sysCalcFireSolution (sysVectorSubtract (objGetPos (objGetTarget gPlayerShip)) (objGetPos gPlayerShip)) (sysVectorSubtract (objGetVel (objGetTarget gPlayerShip)) (objGetVel gPlayerShip)) (typGetDataField (itmGetType (objGetProperty gPlayerShip 'selectedWeapon)) "speed")))

(setq close (abs (subtract now want)))

(if
(gr close 20)
(block (desire)
(setq desire (subtract now 10))
(objSetProperty gplayership 'rotation desire)
(sysAddObjTimerEvent 1 gSource 'ClockMove)
)

(sysAddObjTimerEvent 1 gSource 'TargetNow)
)
)
</ClockMove>


<CounterMove>
(block (now want)
(setq now (objGetProperty gplayership 'rotation))
(setq want
(sysCalcFireSolution (sysVectorSubtract (objGetPos (objGetTarget gPlayerShip)) (objGetPos gPlayerShip)) (sysVectorSubtract (objGetVel (objGetTarget gPlayerShip)) (objGetVel gPlayerShip)) (typGetDataField (itmGetType (objGetProperty gPlayerShip 'selectedWeapon)) "speed")))

(setq close (abs (subtract now want)))

(if
(gr close 20)
(block (desire)
(setq desire (add now 10))
(objSetProperty gplayership 'rotation desire)
(sysAddObjTimerEvent 1 gSource 'CounterMove)
)

(sysAddObjTimerEvent 1 gSource 'TargetNow)
)
)
</CounterMove>



</Events>
</ShipClass>


This works smoothly with 40 facing ships, and should theoretically work also with 120 facing ships, but I have not tried it yet with the 120 version.

ClockMove is the code for a clockwise rotation to the target, and CounterMove is counterclockwise. (I am just running each separately now for testing).

Next, I will try to code in to tell it which direction (clockwise or counterclockwise) to turn, and hopefully, then I will have something to put up on xelerus. I think I've worked out the math to do it, but we will soon see.

This code above slows down the turning by forcing it to turn each time incrementally before it runs the next incremental turn again in the timer.

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Sat Mar 12, 2016 1:44 pm

Okay, this was challenging!

This is the solution I found to the problems with all of your help:

(Target Lock mod is up on xelerus):

http://xelerus.de/index.php?s=mod&id=1513

With Santa Box and Target Lock in your Transcendence extensions- you can find the target Lock device under V for deVices.

The Cardinal Alignment ROM is under N for iNfo.

Note, the target lock device will align to the nearest 90 degree direction if no target is selected.
If a target is selected, it aligns your ship with the target.

Relanat, turning is smooth and in the correct direction. I think this finally cracks that rock we were both hammering.

I learned a lot by referencing your options/solutions in the ship pointing code.

Feel free to use any of this code in your mod. I think the result of this one is more your vision than mine. So, if it steps too much on your toes, let me know, and I'll take it down.

I have not tested it yet with 120 facing ships, so if you test it that way, please leave feedback. It may need some tweaking.

Thanks.

relanat
Militia Commander
Militia Commander
Posts: 328
Joined: Tue Nov 05, 2013 9:56 am

Re: Ship rotation mod idea.

Post by relanat » Wed Mar 16, 2016 2:42 am

Target Lock mod downloaded and I'm very eager to give it a go, and look at the code. I was going nuts working around in circles trying to get something happening so all help (and code) greatly appreciated.

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Fri Mar 18, 2016 12:02 am

This one is very challenging - you should see all the paper I went through trying to figure this out.

relanat
Militia Commander
Militia Commander
Posts: 328
Joined: Tue Nov 05, 2013 9:56 am

Re: Ship rotation mod idea.

Post by relanat » Tue Mar 22, 2016 5:29 am

Beautiful work, marsrocks. I hope you don't mind a friendly interrogation (sp?) about what is happening if you've got time. I'm totally in awe of your coding skills.

So you are creating a one pixel ship 1000 ls in front of where the playership is currently pointing. And telling it to hold.

So the creation of this ship is what starts the playership rotation? Is there a less involved way of doing this or does this way offer other advantages?

When this happens <OnCreate> tells it to run 'CarDirection' on the gSource (which I'm assuming is sctargetlock2?) after 2 ticks. Couldn't you just tell the code to run since other TimerEvents work after here? (so you wouldn't need a TimerEvent in <OnCreate>) Or does it add to the cumulative slowing down of the code to the required speed?

<CarDirection> sets "now" as the current playership direction.
Then if the ship direction is within 45 degrees of the left of a cardinal point (between 45 and 1, 135 and 91, 225 and 181, or 315 and 271) then run "CarClockMove".
Otherwise run "CarCounterMove".

In <CarClockMove> "now" is set again as the playership direction (because it won't carry over from <CarDirection> because the "block nil" made it a local value?).
Then "want" is set as one of the 4 cardinal points (depending on which one the ship is facing closest to).

"close" becomes the difference in degrees between now (playership current direction) and want (cardinal point). The use of the 'abs' function makes this always a positive number.
If close is greater than 20 (why 20?) then the 'desire' block is run.
If it's less than 20 then 'CarTargetNow' is run as a TimerEvent.
So when the ship is pointing within 20 degrees of the cardinal point it will jump to it?

So the ship rotation is decreasing in 10 degree lots? And where are the delays happening? Why the difference in timing of 2 in <CarDirection> and 1 in <CarClockMove>?

From what I can work out;
there is an initial delay of 2 in <OnCreate>,
then another delay of 2 in <CarDirection>,
followed by a delay of 1 in <CarClockMove> for every 10 degree reduction of the ship rotation (which can't be more than 3 in total because there is only 45 degrees to work with),
and a final delay of 1 in <CarTargetNow>.
Does that sound right?

Thanks. I've been struggling with running code in the <Events> block and this has really helped.

And making the '0 or 360 option' and the 'counter-clockwise motion' the default option is brilliant. Cuts out lots of code. Nice.
Also will be using the ;block and ;switch as well. That is so sensible and will save me a heap of time chasing brackets. Thanks.

And I had a panic moment when the Cardinal ROM wasn't in the Santabox. Didn''t realise the contents were randomised :lol:!

Edit: OK, since then I have had zero luck getting <Events> code to run. I'm trying to add <Stuff> type code blocks to the dockscreen <Events> section (both inside OnGlobalPaneInit and outside of it) but it never runs. I'm thinking this is because it won't, for whatever reason, refer to code within it's own <Events> block. This is possibly why you had to use a one pixel ship; so the code was separate and could go 'outside' to find it.

I've aded a non-functioning version. Could someone have a look and let me know what isn't right. It's all over the place because I've tried many different ways. Possibly using a module might work, but would I still need a different ItemType or ShipClass (so no gain really)? Is there not an equivalent to 'goto' from Basic or something?

2ndEdit: NMS, in sjf''s Ras Manuf Station topic, says timers need to be created inside something like <OnCreate>. What other options are there apart from OnCreate?
Attachments
AutoShipPointingNeedForumHelp.xml
(7.82 KiB) Downloaded 12 times

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 23, 2016 1:16 am

Beautiful work, marsrocks. I hope you don't mind a friendly interrogation (sp?) about what is happening if you've got time. I'm totally in awe of your coding skills.

Thanks – but this was very complicated for me – I think our coding skills are probably pretty close to the same.

So you are creating a one pixel ship 1000 ls in front of where the playership is currently pointing. And telling it to hold.

Right. If I didn’t tell it to hold – it could potentially gate out of the system before completing its task. The ship serves as an invisible “virtual” object on which I can run events.


So the creation of this ship is what starts the playership rotation? Is there a less involved way of doing this or does this way offer other advantages?
There probably are other ways. The ship acts as an invisible object that lets me put events on it that I am familiar with – maybe it could also be done with <OnInvokedByPlayer> in the item. Someone with more knowledge will have to answer that. I’m just not sure.


When this happens <OnCreate> tells it to run 'CarDirection' on the gSource (which I'm assuming is sctargetlock2?)

[yes]

after 2 ticks. Couldn't you just tell the code to run since other TimerEvents work after here? (so you wouldn't need a TimerEvent in <OnCreate>) Or does it add to the cumulative slowing down of the code to the required speed?
I think we have to initially have our code fit into one of the pre-defined events – with oncreate being guaranteed to run. Take a look at these two links:
http://wiki.kronosaur.com/modding/xml/s ... s[]=events

http://wiki.kronosaur.com/modding/xml/events


<CarDirection> sets "now" as the current playership direction.
Then if the ship direction is within 45 degrees of the left of a cardinal point (between 45 and 1, 135 and 91, 225 and 181, or 315 and 271) then run "CarClockMove".
Otherwise run "CarCounterMove".

In <CarClockMove> "now" is set again as the playership direction (because it won't carry over from <CarDirection> because the "block nil" made it a local value?).
I think you must be right about this. I was struggling here with the same question – as I had initially created a global event to do these calculations. I found they were not working in the global function – so I fell back to having the code re-do the math at each instance.


Then "want" is set as one of the 4 cardinal points (depending on which one the ship is facing closest to).

"close" becomes the difference in degrees between now (playership current direction) and want (cardinal point). The use of the 'abs' function makes this always a positive number.
If close is greater than 20 (why 20?) then the 'desire' block is run.
If we have 40 facings (360/40=9) then each facing is 9 degrees from the next. With 120 (360/120=3), then each facing is 3 degrees off the next. Also, I don’t want my next to last turn to beyond the target I want – so, if I am moving 10 degrees at a time – then that gives me another 10 degree error to account for and avoid. 10 (potential error from going too far)+9 (if 40 facings)=19. So, I felt like I needed to have a minimum number here of 19 – and 20 degrees is close enough in case I miscalculated. This also gives it a nice snap when it hits the target I want.

If it's less than 20 then 'CarTargetNow' is run as a TimerEvent.
So when the ship is pointing within 20 degrees of the cardinal point it will jump to it?

Yes.

So the ship rotation is decreasing in 10 degree lots?

Yes – you may want to do some experimenting here. I found that when we turned in one direction, I could move with increments as low as 1 degree, but when I tried turning the other direction – the computer refused to round up or down to the desired rotation point – or find the next facing down or up and the ship did not move. So, after experimenting, I decided to go with 10 degrees for each turn. Remember my experiments were with 40 facing ships – so there are bigger gaps in the rotations for each turn/ each facing.
And where are the delays happening? Why the difference in timing of 2 in <CarDirection> and 1 in <CarClockMove>?
Just an accident – not necessary. 1 tick or 2 ticks is like no time at all.


From what I can work out;
there is an initial delay of 2 in <OnCreate>,
then another delay of 2 in <CarDirection>,
followed by a delay of 1 in <CarClockMove> for every 10 degree reduction of the ship rotation (which can't be more than 3 in total because there is only 45 degrees to work with),
and a final delay of 1 in <CarTargetNow>.
Does that sound right?

Yes – each is a tiny fraction of a moment. 1, 2, or 3 are such tiny times that you or I could probably not distinguish that tiny bit of time.

Thanks. I've been struggling with running code in the <Events> block and this has really helped.

And making the '0 or 360 option' and the 'counter-clockwise motion' the default option is brilliant. Cuts out lots of code. Nice.

Yes – I finally figured out the numbers describing a circle - particularly at that point where 360 meets 0 again -are really not sufficient. Our numbering system does not do a circle justice.

Also will be using the ;block and ;switch as well. That is so sensible and will save me a heap of time chasing brackets. Thanks.

Thanks!

And I had a panic moment when the Cardinal ROM wasn't in the Santabox. Didn''t realise the contents were randomised !

Ha = it takes some getting used to.

Edit: OK, since then I have had zero luck getting <Events> code to run. I'm trying to add <Stuff> type code blocks to the dockscreen <Events> section (both inside OnGlobalPaneInit and outside of it) but it never runs. I'm thinking this is because it won't, for whatever reason, refer to code within it's own <Events> block. This is possibly why you had to use a one pixel ship; so the code was separate and could go 'outside' to find it.
Again – no event runs until you have some pre-defined transcode allowed event run first. – so my timers are put in oncreate – and then other events I make up can run from there. The computer is looking for those predefined transcode events – but will not actively look for the ones you make up. Those new ones have to be referenced - and put in the computer’s face so to speak before they will run.


I've aded a non-functioning version. Could someone have a look and let me know what isn't right. It's all over the place because I've tried many different ways. Possibly using a module might work, but would I still need a different ItemType or ShipClass (so no gain really)? Is there not an equivalent to 'goto' from Basic or something?
I will look when I get a chance – but hopefully others will as well.

2ndEdit: NMS, in sjf''s Ras Manuf Station topic, says timers need to be created inside something like <OnCreate>. What other options are there apart from OnCreate?
These are from the wiki – but I think there are others that may be found from doing a search of the board. Some good coders can probably send us to another reference:

http://wiki.kronosaur.com/modding/xml/s ... s[]=events

http://wiki.kronosaur.com/modding/xml/events

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 23, 2016 2:46 am

relanat,

I just took a look at your code and I see that you are calling events from a virtual item.

I have never attempted that before - and don't know if it is even possible ...

way above my paygrade...

I hope one of the better minds on here weighs in.

You should definitely read those two links I posted though relating to events.

Peter
Commonwealth Pilot
Commonwealth Pilot
Posts: 91
Joined: Wed May 07, 2014 1:11 am
Location: New Zealand

Re: Ship rotation mod idea.

Post by Peter » Wed Mar 23, 2016 10:49 am

Sounds great! I don't have the time to look at it now, but is it a finished, polished mod ready for gameplay? Or are there still some kinks. The idea is really neat though, I've had lots of troubles trying to get my ships to face the way I want them to :)
My dream is to one day discover that someone who plays transcendence lives near me and goes to my school. Then I can finally have a friend.
---
Why must I keep running into that wall, impossibility?

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 23, 2016 2:24 pm

Peter,

Relanat is working on "auto ship pointing," something that works internally in your ship, which is not quite finished. The earlier version relanat posted in this thread does point your ship correctly, but he is still working on the code to have the ship rotate more naturally to get into those positions.

I have produced similar mods that are ready to use - depending on what form you prefer: as a missile launcher - a device, or a rom. These are links to the finished mods:

x-ray scope (a missile launcher) - which points your ship at any selected target:

http://www.xelerus.de/index.php?s=mod&id=1510

target lock [a device] which points at the target if a target is selected or at 90 degree angles if no target is selected; and cardinal point alignment rom which points at the nearest 90 degree angle [a rom]:

http://www.xelerus.de/index.php?s=mod&id=1513

Peter
Commonwealth Pilot
Commonwealth Pilot
Posts: 91
Joined: Wed May 07, 2014 1:11 am
Location: New Zealand

Re: Ship rotation mod idea.

Post by Peter » Wed Mar 23, 2016 4:03 pm

Ah, nice.
Thanks, I'll look into them.
My dream is to one day discover that someone who plays transcendence lives near me and goes to my school. Then I can finally have a friend.
---
Why must I keep running into that wall, impossibility?

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 23, 2016 9:08 pm

relanat,

I worked a little with your code.

Just to see if i was correct, I added a simple event into the first mod you posted just to play a message- the event called <code> would not run at all.


Code: Select all

	<ItemType UNID="&vtAddPointToShipsInteriorDockscreen;"
		virtual=	"true"
		>
		
		<Events>
			<OnGlobalPaneInit>
					;scrAddAction adds a line to the right hand side of a dockscreen without having to overwrite the whole dockscreen
					;see TranscendentGeek's 'Using scrAddAction' topic in Modding Reference on the forum for a full explanation
					;the code below tells the game to add an action to the Ship's Interior dockscreen
					;-1 puts the action at the bottom of the list, "Point" is the text that appears in the dockscreen list
					;"P" is the key which will cause the action and is also highlighted in the list
					;scrShowScreen is used to take us to the PointingDockscreen
					
				(if (eq aScreenUNID &dsShipInterior;)
				(block nil
                (sysAddObjTimerEvent 1000 gItem 'code)
					(scrAddAction
                        gScreen
                        'addPointOption
                        -1
                        "Point"
                        "P"
						(scrShowScreen gScreen "&dsPointingDockscreen;")
					)
				)
				)
					;in summary, the above code will take you to the PointingDockscreen when you press "P" in the Ship's Interior dockscreen
			</OnGlobalPaneInit>
			
			
			<code>
			(block nil
		    (plyMessage gPlayer "code event will start now")   
            )
			</code>
			



Note, I tried (sysAddObjTimerEvent 1000 gplayership 'code). (sysAddObjTimerEvent 1000 gsource 'code), and (sysAddObjTimerEvent 1000 gItem 'code).

As far as I can tell you can't add additional events there. So, you may want to create a virtual ship or station to run your turning code from there the same way I did.


Another possibility though is to add your turning code into the further actions after the "[Po]int" command is selected from the ship screen.

For instance:

Code: Select all

			<Actions>
					<Action name="Point North or Up" key="N">
						(block nil
							(objSetProperty gPlayerShip 'rotation 90)
							(scrExitScreen gScreen 'forceUndock)
							
					   (plyMessage gPlayer "add more code and commands here to turn to the north or try referring off to a global function to do the job from this point.")  
; obviously take out the immediate rotation in the first line though when you start to add your code into here
						)
									
					</Action>
I had trouble and failed when I tried to do this with a global function, but you may want to give that a shot. Start with something simple in your code to make sure it is happening at the correct time - like simply playing a message to the player. Then add code a bit at a time to see what you are doing in action. This way you can single out any problems quickly.

In the above example, you would take some of your code event in the new version you posted- and add chunks of it at a time to the block of commands you run under the [N]orth action.

Then just test/fix/test til it works like you want.

(Note, there may also be a way to have it run your string of commands after the player presses P for point instead of going to the new dockscreen, but I am not sure of that, since we are adding that screen action there).

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Re: Ship rotation mod idea.

Post by marsrocks » Wed Mar 23, 2016 9:47 pm

Okay - with a little more testing, you can add a set of command codes to begin when you press P for Point.

Code: Select all

	<OnGlobalPaneInit>
					;scrAddAction adds a line to the right hand side of a dockscreen without having to overwrite the whole dockscreen
					;see TranscendentGeek's 'Using scrAddAction' topic in Modding Reference on the forum for a full explanation
					;the code below tells the game to add an action to the Ship's Interior dockscreen
					;-1 puts the action at the bottom of the list, "Point" is the text that appears in the dockscreen list
					;"P" is the key which will cause the action and is also highlighted in the list
					;scrShowScreen is used to take us to the PointingDockscreen
					
				(if (eq aScreenUNID &dsShipInterior;)
				(block nil
                
					(scrAddAction
                        gScreen
                        'addPointOption
                        -1
                        "Point"
                        "P"
                        (block nil
                         (scrExitScreen gScreen 'forceUndock)
						(plyMessage gPlayer "you can place your codes here to turn the ship - or at least create a virtual ship within this area when the player presses P")   
					)
				)
				)
				)
					;in summary, the above code will take you to the PointingDockscreen when you press "P" in the Ship's Interior dockscreen
			</OnGlobalPaneInit>
			GlobalPaneInit
>

This won't be the whole solution though, because I think you need a timer event for the incremental turns.

I remember you tried to use a loop, which I thought was a really neat idea. I ended up having a timer event call itself repeatedly until we get within 20 degrees (close) of our wanted rotation.

So, consider having the player press "P" and then have the code create the virtual ship when the player does that. From there set your timers on the virtual ship to follow your turning code.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest