-- Create a subclass of the native spring class Script class 'NortsTutorial' (Script) -- Pass the script name to be displayed to the parent constructor function NortsTutorial:__init() super('LUA nortstutorial') self.state = 0 -- Set to true to not have to press enter at start self.onlySinglePlayer = true -- Define commands that this script handles self.commands = {} self.commands[".help"] = self.Help self.commands[".repeat"] = self.Repeat end -- Return the mapname this script wants function NortsTutorial:GetMapName() return "SmallDivide.smf" end -- Return the modname this script wants function NortsTutorial:GetModName() return "xtape.sd7" end -- This function is executed every simulated frame (30 times/sec) function NortsTutorial:Update() -- Perform initialization if self.state == 0 then self.state = 1 x = 1 self:Setup() print("Welcome Commander! ") array = { "In this mission you will be instructed to give your troops " .. " basic commands, and get to know your way around the map.", "These messages will automatically disappear after about 10 seconds." .. " If you wish to view them again, you can press Enter, then type '.repeat' and then press Enter again.", "Pressing pause, will pause the game, allowing you to read a message in your own time." .. " Type '.help' for more infos on .repeat and pausing.", "Now, to get started move your mouse cursor (the pointy arrow) to the edge of the screen." .. " YouŽll notice this changes where you are looking at, by moving the screen in that direction of your cursor" .. " (this is known as scrolling).", "Okay, hoping you have managed to move your screen, weŽll move on to the next part: selecting your units." .. " YouŽre not going to be winning any battles if you canŽt give your units commands," .. " and to be able to command them, you first need to select them.", "Click on any one of your units using your left mouse button." .. " You should see a green square appear around that unit, and a menu popping up on the left," .. " which you can ignore for now. The green square shows you which units you currently have selected. ", "To unselect the unit, left click again on an empty bit of the map (not on a unit)." .. " Clicking on a different unit will select that unit.", "OK, IŽm assuming you managed to select and deselect one or more units by now." .. " (If not remeber you can repeat the last message by pressing Enter," .. " typing ''.repeat'' and then pressing Enter again.)" .. " However it would be much too much trouble to give your units orders one by one." .. " Therefore you can select multiple units at once:", " Click/press and hold down your left mouse button near some units, and then move your mouse over them." .. " You should see a box appearing between where you first clicked," .. " and were you 'dragged' your mouse cursor to. Now let go of the left mouse button," .. " and all the units in the box should be selected.", "If that didnŽt work the first time round, just try again, " .. " Remember to keep the left mouse button pressed while you move your mouse." .. " Otherwise you can play around with selecting and deselecting units (try and see what holding shift does).", "OK, you now should know how to move the screen and select your units," .. " next up is giving them orders. One of the most common orders is moving." .. " If you donŽt have any units selected, select some now. Then right click on an empty part of the map." .. " You should hear the servos/engines of your units revving up ," .. " and see them starting to walk/ drive to where you clicked.", " ", " " } -- Indexes are assigned automagically end -- Run SlowUpdate once every 15 seconds if math.mod(gs.frameNum, 450) == 0 then self:SlowUpdate() end end function NortsTutorial:SlowUpdate() print(array[x]) x = x + 1 if x > 12 then x = 12 end end function NortsTutorial:GotChatMsg(msg, player) local varpos = string.find(msg, " ") local number = false if varpos then number = string.sub(msg, varpos + 1) msg = string.sub(msg, 1, varpos - 1) end local cmd = self.commands[msg] if cmd then cmd(self, number) end end function NortsTutorial:Help(number) print("These commands are available:") print(".help (you just entered this command)") print(".repeat") print("This command will repeat the last message displayed. ") print(".repeat [number]") print("If you wish for for more than just the last message to be shown," .. " then enter the number of messages you want repeated after repeat " .. "(ie.:'.repeat 3' for the last three messages) .") end function NortsTutorial:Repeat(number) -- repeat last message if number then x = x - number print("repeating stated number [" .. number .. "] of messages") else print("repeating message before last") x = x - 2 end end function NortsTutorial:Setup() -- Create a bunch of units for this simple mission units.Load("arm_flash", float3(2006.5, 58.7, 3920.9), 0, false) units.Load("arm_rocko", float3(2273.6, 90.3, 3753.5), 0, false) units.Load("arm_peewee", float3(1887.2, 47.2, 3682.0), 0, false) units.Load("arm_flash", float3(2076.4, 87.8, 3785.9), 0, false) units.Load("arm_peewee", float3(2165.1, 91.3, 3664.6), 0, false) units.Load("arm_stumpy", float3(2081.0, 96.6, 3685.5), 0, false) units.Load("arm_peewee", float3(2184.8, 87.2, 3755.7), 0, false) units.Load("arm_peewee", float3(2126.8, 91.0, 3723.9), 0, false) units.Load("arm_rocko", float3(2197.0, 90.1, 3687.3), 0, false) units.Load("arm_hammer", float3(2179.9, 86.3, 3823.2), 0, false) units.Load("arm_samson", float3(2211.7, 62.4, 3976.9), 0, false) units.Load("arm_rocko", float3(1974.4, 59.1, 3782.7), 0, false) units.Load("arm_hammer", float3(2131.8, 87.1, 3809.2), 0, false) units.Load("arm_stumpy", float3(2244.7, 93.9, 3674.6), 0, false) units.Load("arm_jethro", float3(2274.1, 75.5, 3911.0), 0, false) units.Load("arm_jethro", float3(2161.4, 73.1, 3896.2), 0, false) units.Load("arm_jeffy", float3(2018.8, 89.8, 3620.4), 0, false) units.Load("arm_flash", float3(2012.3, 64.6, 3819.2), 0, false) units.Load("arm_samson", float3(2087.6, 73.7, 3885.5), 0, false) units.Load("arm_peewee", float3(2035.8, 83.2, 3764.2), 0, false) -- Enemy stuff local first = { units.Load("core_crasher", float3(2974.0, 54.4, 3852.5), 1, false), units.Load("core_thud", float3(2952.3, 64.3, 3681.8), 1, false), units.Load("core_ak", float3(2727.1, 58.8, 3622.7), 1, false), units.Load("core_ak", float3(2840.0, 60.6, 3529.0), 1, false), units.Load("core_thud", float3(2928.6, 54.6, 3831.7), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(2900) c:AddParam(80) c:AddParam(3300) for i = 1, table.getn(first) do first[i]:GiveCommand(c) end local second = { units.Load("core_weasel", float3(1114.6, 44.8, 928.2), 1, false), units.Load("core_weasel", float3(915.1, 43.2, 1053.7), 1, false), units.Load("core_instigator", float3(916.7, 43.8, 1130.7), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(1300) c:AddParam(80) c:AddParam(800) for i = 1, table.getn(second) do second[i]:GiveCommand(c) end local third = { units.Load("core_instigator", float3(1050.5, 44.2, 3450.7), 1, false), units.Load("core_ak", float3(944.5, 48.4, 3421.6), 1, false), units.Load("core_ak", float3(819.6, 64.4, 3568.9), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(1200) c:AddParam(80) c:AddParam(3100) for i = 1, table.getn(third) do third[i]:GiveCommand(c) end local fourth = { units.Load("core_storm", float3(3196.9, 317.7, 2018.1), 1, false), units.Load("core_ak", float3(3092.6, 293.2, 2004.6), 1, false), units.Load("core_ak", float3(3269.4, 280.7, 1959.9), 1, false), units.Load("core_storm", float3(3001.3, 353.1, 2054.6), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(3700) c:AddParam(80) c:AddParam(2000) for i = 1, table.getn(fourth) do fourth[i]:GiveCommand(c) end local fifth = { units.Load("core_weasel", float3(1894.7, 43.1, 2114.7), 1, false), units.Load("core_slasher", float3(2332.4, 58.0, 1514.5), 1, false), units.Load("core_instigator", float3(1983.7, 48.6, 1918.6), 1, false), units.Load("core_instigator", float3(2294.1, 43.3, 1655.8), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(2000) c:AddParam(80) c:AddParam(2000) for i = 1, table.getn(fifth) do fifth[i]:GiveCommand(c) end local sixth = { units.Load("core_slasher", float3(3010.4, 65.8, 940.0), 1, false), units.Load("core_raider", float3(2793.9, 77.6, 916.4), 1, false), units.Load("core_instigator", float3(2972.0, 67.1, 924.0), 1, false), units.Load("core_ak", float3(2493.5, 41.2, 487.1), 1, false) } local c = Command() c.id = Command.PATROL c:AddParam(3100) c:AddParam(80) c:AddParam(1200) for i = 1, table.getn(sixth) do sixth[i]:GiveCommand(c) end end -- Instantiate the class so that it is registered and shown NortsTutorial = NortsTutorial()