From the structure of your code, it seems that you wanted to use syltest < 50
in the conditions of if
and elseif
, instead you used _2sylchoice < 50
. Moreover, perhaps you meant _2sylchoice = _2syl1
(is there a typo?).
See what you mean:
function NameGen() preftest = math.random(100) syltest = math.random(100) sufftest = math.random(100) pref1 = "New " _1syl1 = "Lon" _2syl1 = "Don"; suff1 = " City" prefchoice = pref1 _1sylchoice = _1syl1 _2sylchoice = _2syl1 suffchoice = suff1 if preftest < 50 and syltest < 50 and sufftest < 50 then cityname = prefchoice .. _1sylchoice .. _2sylchoice .. suffchoice elseif preftest < 50 and syltest < 50 then cityname = prefchoice .. _1sylchoice .. _2sylchoice else cityname = _1sylchoice end end for i = 1, 100 do NameGen() print(cityname) end
Aside, you are using too many global variables. All the variables you use should be local unless you have a good reason for this (although I did not modify this aspect of your code so as not to confuse you if you did not know what I'm talking about).
source share