speedometer

Post about your finished mods here.
Post Reply
raniadoll
Anarchist
Anarchist
Posts: 1
Joined: Tue Sep 10, 2013 2:40 pm

Requested by LordoCarrot on IRC and coded by me, this is the fruition of a few hours (read 6-8 hours) that I spent coding, debugging, testing, and polishing a mod. This mod adds a speedometer that shows players the speed of all the ships on the screen in terms of c (the light speed constant) and also displays the names of ships flying around. This is more of a newbie boost since most veteran players know the relative speeds of ships in game anyways.
rania
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Hello raniadoll,
ODM Speedometer is a mod by RPC, what are you saying ?

[also I splitted the post from TVR's ICX mod, since this doesn't belong there]
mordrax
Anarchist
Anarchist
Posts: 7
Joined: Sat May 09, 2015 2:57 am

Sorry to necro this thread. Tried to use Speedometer on 1.6beta3 and it was experiencing alot of slowdowns, found the following in the debug.log file. Note this is only 10ms. Throws this much exceptions per 10ms making it unplayable with this extension.

Code: Select all

05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436587224)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436587224) [(436587224)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436580616)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436580616) [(436580616)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436591472)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436591472) [(436591472)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436587696)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436587696) [(436587696)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436590056)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436590056) [(436590056)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436583920)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436583920) [(436583920)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436592888)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436592888) [(436592888)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436591000)
05/10/2015 13:50:11	NPCSpeedometer [Wolfen-class gunship .01c ]: Exception in objDestroy; arg = (436591000) [(436591000)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436592416)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436592416) [(436592416)] ### (ObjDestroy gSource) ###
05/10/2015 13:50:11	Crash in CSpaceObject::Destroy
05/10/2015 13:50:11	Exception in objDestroy; arg = (436589584)
05/10/2015 13:50:11	NPCSpeedometer [Speedometer station]: Exception in objDestroy; arg = (436589584) [(436589584)] ### (ObjDestroy gSource) ###
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Yeah the speedometer is actually a computationally intensive code monster since I update every tick to check for 1. Ships near the player, 2. Ship speeds.
I can probably clean up the code and update if requested.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
mordrax
Anarchist
Anarchist
Posts: 7
Joined: Sat May 09, 2015 2:57 am

I found it to be a nifty little feature, quite insightful. It seems to work well until you hit any asteroid field which made me think it was the new graphics causing it. Maybe it's mistakenly trying to calculate the speed of each asteroid?

However, not a big deal without it and with a brief glance, it does not look trivial to debug and fix so let's hold off until someone else mentions it :)
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

I will look at it.
Download and Play in 1.9 beta 1...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!
Star Castle Arcade: Play a classic arcade game adventure, with or without more features (like powerups)!
Playership Drones: Buy or restore exotic ships to command!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

Rewrote and updated the mod to 1.5 (and it works in 1.6 beta). Cut-and-paste the code below to a fresh xml file, or replace all code in speedometer.xml. RPC may replace his code with mine below and reupload if he desires.

Code: Select all

<?xml version="1.0" ?>
<!DOCTYPE TranscendenceExtension
[
	<!ENTITY unidSpeedometer	"0xe1286050">
	<!ENTITY vtSpeedometer		"0xe1286051">
]>

<TranscendenceExtension UNID="&unidSpeedometer;"
	name="Ship Speedometer"  apiVersion="25"  credits="Original mod by RPC; Rewritten and updated to 1.5 by PM" >

	<StationType UNID="&vtSpeedometer;"
		name="(speedometer)"  noArticle="true"  sovereign="&svIndependent;"  immutable="true"  noMapIcon="true"  virtual="true" >

		<Events>
			<OnCreate>
				; Check three times per second.
				(sysAddObjRecurringTimerEvent 10 gSource "speedometer")
			</OnCreate>

			<OnGlobalPaneInit>
				; Ships broadcasting speeds constantly can squelch important messages from them,
				; so allow player to toggle them on or off.  Offer toggle when player checks status.
				(if (and (eq aScreen "&dsShipInterior;") (eq aPane "Default"))
					; YES:  Offer toggle.
					(block (theText)
						(setq theText (cat
							"Toggle Speedometer: "
							(if (typGetData &vtSpeedometer; "noSpeedometer") "OFF" "ON")
						))
						(scrAddAction gScreen 'SpeedometerRPC 0 theText "T"
							(block Nil
								(typSetData &vtSpeedometer; "noSpeedometer"
									(if (typGetData &vtSpeedometer; "noSpeedometer") Nil True)
								)
								(scrRefreshScreen gScreen)
							)
						)
					)

					; NO:  Nothing to do here.
				)
			</OnGlobalPaneInit>

			<OnGlobalSystemCreated>
				(if (not (sysFindObject Nil "tNV +unid:&vtSpeedometer;"))
					; YES:  Spawn dummy at the star.
					(sysCreateStation &vtSpeedometer; (objGetPos Nil))

					; NO:  Already found a dummy!
					Nil
				)
			</OnGlobalSystemCreated>

			; OnUpdate does not work on this.
			<speedometer>
				(if (and  gPlayerShip  (not (typGetData &vtSpeedometer; "noSpeedometer")) )
					; YES:  All nearby ships broadcast their name and speed.
					(block Nil
						(setq speedTalk (lambda (theObj)
							(if (and theObj (objIsShip theObj))
								; YES:  Speak!
								(block (theSpeed desc)
									(setq theSpeed (sysVectorSpeed (objGetVel theObj)) )
									(if (geq theSpeed 100)
										; YES:  Lightspeed or faster.
										(block Nil
											(setq desc (divide theSpeed 100))
											(setq theSpeed (subtract theSpeed (multiply desc 100)))
										)
										; NO:  Sublight speed.
										(setq desc "")
									)
									(if (ls theSpeed 10)
										; YES:  Speed less than 10 shows as single digit, so pad a zero infront of it!
										(setq desc (cat desc ".0" theSpeed "c"))

										; NO:  Double digits
										(setq desc (cat desc "." theSpeed "c"))
									)
									(objSendMessage gPlayerShip theObj desc)
								)
								; NO:  Silence!
							)
						))

						; Show player's speed.
						(speedTalk gPlayerShip)

						; Show nearby ships' speed.
						(enum (sysFindObject gPlayerShip "s A N:30 P") thisOne (speedTalk thisOne))
					)

					; NO:  Either player is gone or speedometer is off.
				)
			</speedometer>
		</Events>
	</StationType>

</TranscendenceExtension>
Download and Play in 1.9 beta 1...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!
Star Castle Arcade: Play a classic arcade game adventure, with or without more features (like powerups)!
Playership Drones: Buy or restore exotic ships to command!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
mordrax
Anarchist
Anarchist
Posts: 7
Joined: Sat May 09, 2015 2:57 am

Thanks PM! I tried to do a compare on the two (to get some understanding of modding) and then realised it's a *complete* rewrite! and quite alot smaller too, with a toggle to boot. awesome!

Curiosity lead me to finding out the scripting language used is TLisp and am currently scrolling through the function legend on the wiki to work out what you're actually doing in the mod hehe
mordrax
Anarchist
Anarchist
Posts: 7
Joined: Sat May 09, 2015 2:57 am

Tried it last night, looked great and responsive for a while but then periodically, it would display text on the edge of the monitor and slowdown really badly again. I also couldn't find the 'Toggle speedometer' menu option when looking at the ship options through 's'. Tried all the submenus too. Could it be conflicting with other mods? I have quite a few others ... ... actually, I just realised that I had renamed the original speedometer-ori.xml, but kept it in the same folder. It'll still pick it up won't it *facepalms*.
Post Reply