SimHub JavaScript n...
 
Notifications
Clear all

SimHub JavaScript newby - repetition of calcs - or is there a better way?

4 Posts
2 Users
1 Reactions
2,025 Views
(@mileseven)
Active Member
Joined: 4 years ago
Posts: 8
Topic starter  

I’m charging ahead with my first SimHub project to build a dash that analyses and presents tyre slip data under acceleration and braking in rf2.

I’ve adopted JavaScript for my calculations as I used to write VBA in a previous life.

Everything is working fine but I’m finding that I’m duplicating calculations and gamedata calls quite a lot - e.g. to drive a dial gauge to show tyre slip - but also using essentially the same calculations to drive a couple of calculated-colour overlays used as dial backgrounds. And then there are optional gauges/displays that compare left/right and front/back relative slip...

Soon adds up. I’m guessing the processing overhead is not too horrific compared to some complicated dashes - but for maintenance reasons alone, is there a way of creating/sharing functions (or calculated values) across multiple items in the same dash?

I noted the mention of [root]variables in the GitHub simhub JS page but wasn’t sure if it addressed what I’m looking for....?


   
gaelibus reacted
Quote
(@gaelibus)
New Member
Joined: 3 years ago
Posts: 2
 

Hi, did you solve this issue?

It also looks to me that there should be a way to insert javascript functions in the javascript loop to support better coding and rendering efficiency. Possibly at overlay and/or dashboard levels...


   
ReplyQuote
(@mileseven)
Active Member
Joined: 4 years ago
Posts: 8
Topic starter  

@gaelibus - not really. In the end, I’ve not experienced a meaningful overhead and so didn’t try to optimise it once I’d got the basics working. I’m still interested in a solution though as I’m thinking about further projects and they’re only ever likely to be increasingly complicated….


   
ReplyQuote
(@gaelibus)
New Member
Joined: 3 years ago
Posts: 2
 

@mileseven thanks for the feedback! Let see if this post catches the attention of the developer and he can share its view on this!

I think it would absolutely make sense to enable such capability, if it is not open already… it would certainly make SimHub even more applealing, I guess.

This post was modified 3 years ago by gaelibus

   
ReplyQuote
Share: