Board index FlightGear Development Nasal

setprop - to a float?

Nasal is the scripting language of FlightGear.

setprop - to a float?

Postby Algernon » Mon Aug 30, 2010 7:46 pm

I'm only just learning Nasal, and I don't have a head for code, so I'd appreciate a bit of guidance.

I'm experimenting with an idea to create a reasonably realistic electrical system for the Eurofighter Typhoon, with redundancy for most eventualities (except, I think, running out of fuel, which can happen easily in the Typhoon!) but with realistic-ish effects if they do happen. I am currently running a third 'engine' which outputs a negligible thrust, but whose N values are used by Nasal to calculate a raw voltage - as the APU revs up (to a preset level), so the voltage increases until it flattens out at operating level, and feeds into the main bus.

Effectively, I'm now trying to use Nasal to revalue the property values created by the electrical.xml to actually be relevant to this aircraft's power systems and their status at any point.

My problem is getting the correct property type - my Nasal scripts return everything as doubles, whereas the voltage property is a float. The electrical system isn't registering any voltage provided by the APU, though the script is working perfectly before it reaches the electrical system. I could be going about this entirely the wrong way, in which case do tell me, but I'm afraid scouring the Nasal website and searching the forums has not produced any understandable explanations for a code-dunce of my calibre.

Here's the code, in case it helps, basically I know nothing, just trying to branch out from the HowTo on writing simple Nasal scripts...
Code: Select all
var apuVolts = func{

  var turbineN = getprop("/engines/engine[2]/n2");
  var volts = turbineN * 2.4;
 
  setprop("systems/electrical/suppliers/APU", volts);
  setprop("controls/APU/indicated-volts", volts);
  settimer(apuVolts, 0.5);
  }
 
setlistener("/engines/engine[2]/n2", apuVolts);


Thanks in advance :)
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
Developer: Eurofighter EF2000 - English Electric Lightning - Handley Page Victor
User avatar
Algernon
 
Posts: 507
Joined: Sun Jun 27, 2010 4:55 pm
Callsign: G-ALGY
Version: 2019.1.1
OS: Win10

Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests