How can I use multiple user input variables in else statements?

Willkommen in der Transport Fever Community

Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.

 

Die Registrierung und Nutzung ist selbstverständlich kostenlos.

 

Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.

Das Team der Transport-Fever Community


  • Hello all,


    is it possible to use multiple variables in the ELSE statement of a construction file? For a building asset I want to use 3 separate input variables for the user the choose a model. Based on the combination of the 3 selections the mdl file must then be defined from the else statement in the updateFn. But I can't find a way to use all 3 parameters at once, e.g. with an AND or nested ELSE statements. Here below a theoritical example of the nested ELSE, it doesn't return errors, but the models bko_b*.mdl's aren't returned in game.


    if params.bko_a == 0 then  result.models[#result.models+1] = { id = "building/bko_aa.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }

    elseif params.a == 1 then result.models[#result.models+1] = { id = "building/bko_ab.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }

    elseif params.a == 2 then

    if params.b == 0 then result.models[#result.models+1] = { id = "building/bko_vollmer5605/bko_ba.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } } }

    elseif params.b == 1 then  result.models[#result.models+1] = { id = "building/bko_vollmer5605/bko_bb.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } } }

    elseif params.b == 2 then result.models[#result.models+1] = { id = "building/bko_vollmer5605/bko_ba.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }

    result.models[#result.models+1] = { id = "building/bko_vollmer5605/bko_bb.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }

    end

    elseif params.a == 3 then  result.models[#result.models+1] = { id = "building/bko_ac.mdl", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }

    end


    Anyone who knows how to get round this?


    Thanks, Danke,

    B|ko


    PS Antworten auf Deutsch sind ebenfalls willkommen

    Reply in German if you want, but allow me to stick to English.

    Einmal editiert, zuletzt von dview ()

  • Possibly stupid question: Is this an example code or the actual one?


    The first checked variable is params.bko_a; in the subsequent elseifs, You check for params.a only. If this is not intended AND the actual name of the variable is params.bko_a, it may well be the reason for the problem: then, the game will never come around to checking params.b.

  • So, if a==2, the parameter b should be evaluated? What is happening in this case?

    From the code, this should work (if names are right).


    Also, consider using a variable local model that you can assign the path in the if conditions and in the end id=model, because this is a lot of redundant code.

BlueBrixx