1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
if not MonoBehaviour then import"UnityEngine" end
local City = require("City") local Road = require("Road")
function main() local a = 2 local b = 2.335 local c = "ccc" local c2 = 'cc2234' local d = true local e = [===[alo123"]===]
print("this is Test.txt", a, b, c, c2, d, e, f) print("a = " .. a .. ", b = " .. b) local t = {[1] = 3, ["a"] = 4, [3] = 5} print(t[1], t["a"], t[3])
test() classTest() listTest() dictinaryTest() unityTest() end
function test() print("test") local f = 2; if f == a then print("aaa") else print("bbb") end
local count = 3 for i = 1, count do print("i = ", i) end
while count > 0 do print("count = ", count) count = count - 1 end
count = 3 repeat print("-- count = ", count) count = count - 1 until count < 0
print("random = ", random()) count, a, b, c = random() print("count = ", count, "a = ", a, "b = ", b, "c = ", c) end
function random() return Random.Range(0, 100), 2, 3, "addd" end
function classTest() local city = City:new(100,200)
print(city:toString()) print(city.toString(city))
local road = Road:new() road:setPos(3, 3) print("road.x = " .. road.x .. ", road.z = " .. road.z) print(road:toString()) end
function listTest() local cityList = {} print("len = " .. table.getn(cityList)) print("len = " .. #cityList) for i=1,10 do local r = Road:new() r:setPos(i, i) table.insert(cityList, 1, r) end
table.remove(cityList, 1)
for i=1,#cityList do print(cityList[i]:toString()) end end
function dictinaryTest() local dic = {}
for i = 1, 10 do local r = Road:new() r:setPos(i, i) dic[i] = r end
table.remove(dic, 3)
for i = 1, table.getn(dic) do print("dic[" .. i .. "] = " .. dic[i]:toString()) end end
function unityTest() local gameObj = GameObject.Find("Main Camera") print("name = " .. gameObj.name) local c = coroutine.create(coroutineTest) print("coutine.create") coroutine.resume(c) print("coutine.resume") end
function coroutineTest() local go = GameObject("test") go:SetActive(false) print("go:SetActive(false)") Yield(WaitForSeconds(2)) go:SetActive(true) print("go:SetActive(true)") Yield(WaitForSeconds(2)) GameObject.Destroy(go) print("Destroy(go)") end
|