function checkPrivateLeft()
if getObject("Values[str_private_left]"):getStr(VValueString) == getObject("Values[RandomCode]"):getStr(VValueString) then
getObject("Values[str_private_left]"):setValue(VValueString, getObject("Values[RandomCode]"):getStr(VValueString) .. "(OK)")
getObject("Conditions[PrivateLeftCodeOK?]"):setValue(VConditionValue, true)
else
getObject("Values[str_private_left]"):setValue(VValueString, "WRONG CODE")
end
end
function checkPrivateLeft()
strRandomCode = "10041"
if getObject("Values[str_private_left]"):getStr(VValueString) == strRandomCode then
getObject("Values[str_private_left]"):setValue(VValueString, strRandomCode .. "(OK)")
getObject("Conditions[PrivateLeftCodeOK?]"):setValue(VConditionValue, true)
else
getObject("Values[str_private_left]"):setValue(VValueString, "WRONG CODE")
end
end
strRandomCode = math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9) -- global randomized 5 digit code on game start. (can access it via any script).
-- print( strRandomCode) -- uncomment to find out what the code is.
function checkPrivateLeft()
if Values["str_private_left"].String == strRandomCode then
Values["str_private_left"].String = strRandomCode .. " (OK)"
Conditions["PrivateLeftCodeOK?"].ConditionValue = true
else
Values["str_private_left"].String = strRandomCode .. " (WRONG CODE)"
end
end
@ Simon: it's string because he want to add text to it. I believe he's using them to display messages via displayed text action part on a console screen or something.
Looks good. Did you animate the keypad button presses? I also see you opted to add extra 10ms to the displayed text pause time to prevent flickering.
Values["str_private_left"].String == strRandomCode .. " (OK)"
Values["str_private_left"].String == strRandomCode .. " (WRONG CODE)"
function setRndCode(val, amt)
Values[val].String = ""
for i = 1, amt do Values[val].String = Values[val].String .. math.random(0,9) end
end
setRndCode("v_rand_code", 5) -- create 5 digit random combination inside of value "v_rand_code"
local strRandomCode
strRandomCode = math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9)
local strRandomCode = math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9) .. math.random(0,9)
Values["value_name"].Int = strRandomCode -- set integer value of "value_name" to strRandomCode value
Values["value_name"].String = strRandomCode -- set string value of "value_name" to strRandomCode value