-- MoveTo Lua Example function SteamDetails() ModBase.SetSteamWorkshopDetails("MoveTo", "Shows how to use various Move to functions", {"Moving", "Example"}, "Image.png") end function AfterLoad_CreatedWorld() -- Set start location of player to 20,20 ModPlayer.SetPlayerStartLocation(20,20) end -- Var - Object ID (hold) ObjId = -1 -- Var - Finished Moving MoveComplete = false function AfterLoad() -- Width and Height of map local Width = ModTiles.GetTilesWide() local Height = ModTiles.GetTilesHigh() -- Get a table of results with all the Berries in the world ObjectIDs = {} ObjectIDs = ModTiles.GetObjectsOfTypeInAreaIDs("Berries", 0,0, Width - 1, Height - 1) -- Only using the first result - check if valid (Hold as ObjId if valid) if(ObjectIDs[1] ~= -1) then ObjId = ObjectIDs[1] end -- Start the move if(ObjId ~= -1) then -- Start the Move ModObject.StartMoveTo(ObjId, 0,0, 10, 0) end end function OnUpdate() -- If move not completed and valid, update if(MoveComplete == false and ObjId ~= -1) then MoveComplete = ModObject.UpdateMoveTo(ObjId, true, true) end -- Get player location Pos = ModPlayer.GetPlayerLocation() if(Pos[1] ~= nil) then -- ModDebug.Log(Pos[1], Pos[2]) -- (X, Y) end end