LUATutorials
Tutorials must be registered in the tutorial registry. Instance ID ff7d91e7 at the bottom. Format is "tutorial_registry : add_tutorial(hex2dec('abfad020'), 0, 'timbuktu')" where the id is the tutorial guid, 0 is the order of tutorials, and timbuktu is the region directory it's in.
The tutorial scripts actually begin with a series of definitions and functions in order to set the properties for how various things in the tutorials are determined. These only need to be defined once. The other two scripts simply call on these definitions in order to determine things
All tutorials are made based on Steps. a step is an independant thing that you do inside a tutorial. when you complete what is requested you move onto the next step. Tutorials consist of lots of these steps followed by an ending block. Here's an example step and ending block with descriptions where possible
Specification --------------------------
Start Block -- Primary Tutorial only
tutorialtasks = { n = 0 } -- Primary Tutorial tutorial_number_index = { } -- Set Tutorial Index tutorial_decal_color_type = {} -- Decal table tutorial_decal_color_type.DECAL_YELLOW = "selection_yellow" tutorial_decal_color_type.DECAL_GREEN = "selection_green" tutorial_file_guids = {} tutorial_file_guids[1] = "0x8a5b7a6c" tutorial_file_guids[2] = "0xea5d6dc8" tutorial_zone_type = { } tutorial_zone_type.kZoneTypeUndefined = 0 tutorial_zone_type.kZoneTypeLowDensityResidential = 1 tutorial_building_type = {} tutorial_building_type.kOilPowerPlant = "0x1f420000" tutorial_building_type.kCoalPowerPlant = "0x1f4d0000" tutorial_dispatch_type = {} tutorial_dispatch_type.kDispatchTypePolice = 0 tutorial_dispatch_type.kDispatchTypeFire = 1 tutorial_network_type = { } tutorial_network_type.kRoad = 0 tutorial_network_type.kRail = 1 tutorial_buttons = {} tutorial_buttons.kButtonDemolish = "0xe999c820" tutorial_buttons.kButtonDezone = 0 tutorial_buttons.kButtonLowDensityResidential = "0x01" tutorial_base_task_action = { which_function = 0, startX = 0, startZ = 0, endX = 0, endZ = 0, guid = 0, } tutorial_function_index = {} tutorial_function_index.UNDEFINED = 0 -- Functions that ask users to do some task -- and check if users succeeds or not -- ASK_TO_ZONE_AND_CHECK = 1, tutorial_function_index.ASK_TO_ZONE_AND_CHECK = 1 (All functions designated in this block. Functions may be called from inside a command or may be inside any step independantly.) EX. function set_camera(object, XCoord, ZCoord) object.cameraX = XCoord; object.cameraZ = ZCoord; end
Step Block
-- Step # --- a = tutorial_create_task("0a39f624") - Create step with this GUID a.task_action = tutorial_check_button_clicked_no_arrow(tutorial_buttons.kButtonTerraform) -- Task which is based off a defined function from above tutorial_button_set(a, -- Set buttons based from the tutorial button function tutorial_buttons.kButtonTerraform, tutorial_buttons.kPuckButtonGod, tutorial_buttons.kButtonZoomIn, tutorial_buttons.kButtonZoomOut) a.zoomLevel = 0; -- Zoom level for step set_camera(a,68,60) -- From defined function above a.instruction_msg = [[text@0x8a5ae472]] -- Locale IID for text. Define afterwards for lack of data possibilities if you want a.try_again_msg = [[text@ea4ad695]] -- Locale IID for text. Define afterwards for lack of data possibilities if you want a.congratulation_msg = [[text@8a5adc16]] -- Locale IID for text. Define afterwards for lack of data possibilities if you want
End Block
tutorial_number_index[2] = tutorialtasks.n+1 -- Tutorials completed (now 2) print ("second tutorial script") -- Order of this script in the tutorial list print (tutorial_number_index[2]) -- Location of this tutorial in index (second) dofile("tutorial_tasks3.lua") -- Next tutorial call --print(tutorialtasks[1].task_action) print(tutorialtasks[1].target_buttons[1]) -- Print first target button --print(tutorialtasks[3].target_buttons[1]) --print(tutorialtasks[5].target_buttons[1]) --print(tutorialtasks[4].task_action.target_guids)