FANDOM


--
-- Important things in LUA
-- Comments start -- and ~= is the not equal operator NOT !=
-- http://www.compileonline.com/execute_lua_online.php is a good IDE and and testing site 
-- http://www.lua.org/manual/5.1 for an LUA Reference Manual
--
 
local funcs = {}
 
function ReadArgs ( string_ )
--Converts an engine data string into an engine LUA structure computing extra values as needed
 
  local engine = {
name="",
intlnames="CS: Vlaštovka - DA: Svale - DE: Schwalbe - PT: Carvoeiro",
image="Swallow.png",
era=0,
tractiveforce=0,
tforce_upgrd1_name="",tforce_upgrd1_value=0,tforce_upgrd1_cost=0,tforce_upgrd1_rescost=0,
tforce_upgrd2_name="",tforce_upgrd2_value=0,tforce_upgrd2_cost=0,tforce_upgrd2_rescost=0,
reliability=0,
rel_upgrd1_name="",rel_upgrd1_value=0,rel_upgrd1_cost=0,rel_upgrd1_rescost=0,
rel_upgrd2_name="",rel_upgrd2_value=0,rel_upgrd2_cost=0,rel_upgrd2_rescost=0,
acceleration=0,
acc_upgrd1_name="",acc_upgrd1_value=0,acc_upgrd1_cost=0,acc_upgrd1_rescost=0,
acc_upgrd2_name="",acc_upgrd2_value=0,acc_upgrd2_cost=0,acc_upgrd2_rescost=0,
speed=0,
speed_upgrd1_name="",speed_upgrd1_value=0,speed_upgrd1_cost=0,speed_upgrd1_rescost=0,
speed_upgrd2_name="",speed_upgrd2_value=0,speed_upgrd2_cost=0,speed_upgrd2_rescost=0,
cost=0,
researchcost=0,
service70=0,
prerequisites="",
sellprice=0
}
 
  local s_pos = 1
  local c_pos = string_.find(string_,",",s_pos)
  local e_pos = 1
  if (c_pos~=nill) then e_pos = string_.find(string_,"\n",c_pos) end
  while ( s_pos~=nill and c_pos~=nill ) do
    if e_pos==nill then e_pos=string_.len(string_)+1 end
    engine[string_.sub(string_,s_pos,c_pos-1)] = string_.sub(string_,c_pos+1,e_pos-1)
    s_pos = e_pos+1
    c_pos = string_.find(string_,",",s_pos)
    if (c_pos~=nill) then e_pos = string_.find(string_,"\n",c_pos) end
  end
 
  engine.max_tractiveforce = engine.tractiveforce+engine.tforce_upgrd1_value+engine.tforce_upgrd2_value
  engine.max_reliability = engine.reliability+engine.rel_upgrd1_value+engine.rel_upgrd2_value
  engine.max_acceleration = engine.acceleration+engine.acc_upgrd1_value+engine.acc_upgrd2_value
  engine.max_speed = engine.speed+engine.speed_upgrd1_value+engine.speed_upgrd2_value
  engine.max_wsp = engine.max_speed*engine.max_tractiveforce
 
  engine.average_reliability = (2-((1-(engine.max_reliability/100))/3))
  engine.average_speed = engine.max_speed*engine.average_reliability
  engine.average_wsp = engine.max_wsp*engine.average_reliability
  engine.average_reliability = engine.average_reliability*100
 
  return engine
end
 
function funcs.PrintName (frame)
  local s = frame.args[1]
  local engine = ReadArgs (s)
  return "Processed data and the name found was ",engine.name
end
 
function funcs.PrintArg (frame)
  return frame.args[1];
end
 
function funcs.Print ()
  return "Print Test"
end
 
return funcs

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.